leminhkt

76

Sep 9th, 2020
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. const short LOVE = 1411;
  6.  
  7.  
  8. void query() {
  9.     int n; string m;
  10.     cin >> n >> m;
  11.     int D = 0, S = 0;
  12.     for (int i = 0; i < n; ++i){
  13.         D += (m[i] == 'D');
  14.         S += (m[i] == 'S');
  15.     }
  16.     if ((D&1) || (S&1)) {
  17.         cout << 0;
  18.         return;
  19.     }
  20.     for (int a = 0; a < n; ++a)
  21.         for (int b = a, d = 0, s = 0; b < n; ++b) {
  22.             d += (m[b] == 'D');
  23.             s += (m[b] == 'S');
  24.             if (d == D/2 && s == S/2) {
  25.                 cout << a + 1 << ' ' << b + 1;
  26.                 return;
  27.             }
  28.         }
  29.     cout << 0;
  30. }
  31.  
  32.  
  33. int main(){
  34.     //freopen("Test.INP", "r", stdin);
  35.     //freopen("Test.OUT", "w", stdout);
  36.     cin.tie(NULL)->sync_with_stdio(false);
  37.  
  38.  
  39.     int t; for (t = 1; t--;) query();
  40.  
  41.  
  42.     return 0;
  43. }
Advertisement
Add Comment
Please, Sign In to add comment