#include <iostream>
#include <vector>
using namespace std;
void solve(){
int n;
cin >> n;
vector<char> s(n);
for(auto &i : s) cin >> i;
for(int i = 0; i < n - 1; i++){
for(int j = i + 1; j < n - 1; j++){
if(s[i] == s[i+1] && s[j] == s[j+1]){
cout << "Solution is: " << i + 1 << " " << j + 1;
return;
}
cout << "No solution";
signed main(){
solve();
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
#include <vector>
using namespace std;
void solve(){
int n;
cin >> n;
vector<char> s(n);
for(auto &i : s) cin >> i;
for(int i = 0; i < n - 1; i++){
for(int j = i + 1; j < n - 1; j++){
if(s[i] == s[i+1] && s[j] == s[j+1]){
cout << "Solution is: " << i + 1 << " " << j + 1;
return;
}
}
}
cout << "No solution";
}
signed main(){
solve();
}