Advertisement
Promi_38

cf 1569A

Sep 22nd, 2021
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.51 KB | None | 0 0
  1. #include<bits\stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.     int t;
  8.     scanf("%d", &t);
  9.     while(t--)
  10.     {
  11.         int n, flag, j;
  12.         scanf("%d", &n);
  13.         string s;
  14.         cin >> s;
  15.         flag = 0;
  16.         for(j = 0; j < n; j++)
  17.         {
  18.             if((s[j] == 'a' && s[j+1] == 'b') || (s[j] == 'b' && s[j+1] == 'a') )
  19.             {
  20.                 printf("%d %d\n", j+1, j+2);
  21.                 flag = 1;
  22.                 break;
  23.             }
  24.         }
  25.         if(flag == 0) printf("-1 -1\n");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement