-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path113a.cpp
37 lines (34 loc) · 1.03 KB
/
113a.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define LL long long
#define mod 1000000007
#define FOR(i, j, k) for (int i=j ; i<k ; i++)
#define ROF(i, j, k) for (int i=j ; i>=k ; i--)
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
const long long INF = 1e18;
const long long MAX = 1e5+10;
int main(){
fastio;
int t; cin>>t;
while(t--){
int n; cin>>n;
string s; cin>>s;
bool ok = false;
FOR(i,0,n){
int a=0,b=0;
FOR(j,i,n){
if(s[j]=='a') a++;
else b++;
if(a==b) {
cout<<i+1<<" "<<j+1<<"\n";
ok = true;
break;
}
}
if(ok) break;
}
if(!ok) cout<<-1<<" "<<-1<<"\n";
}
}