Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- const short LOVE = 1411;
- void query() {
- int n; string m;
- cin >> n >> m;
- int D = 0, S = 0;
- for (int i = 0; i < n; ++i){
- D += (m[i] == 'D');
- S += (m[i] == 'S');
- }
- if ((D&1) || (S&1)) {
- cout << 0;
- return;
- }
- for (int a = 0; a < n; ++a)
- for (int b = a, d = 0, s = 0; b < n; ++b) {
- d += (m[b] == 'D');
- s += (m[b] == 'S');
- if (d == D/2 && s == S/2) {
- cout << a + 1 << ' ' << b + 1;
- return;
- }
- }
- cout << 0;
- }
- int main(){
- //freopen("Test.INP", "r", stdin);
- //freopen("Test.OUT", "w", stdout);
- cin.tie(NULL)->sync_with_stdio(false);
- int t; for (t = 1; t--;) query();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment