Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- using namespace std;
- string s;
- vector<ll> a[3];
- int main()
- {
- //freopen("in.txt", "r", stdin);
- freopen("TOURS.inp", "r", stdin);
- freopen("TOURS.out", "w", stdout);
- ios_base::sync_with_stdio(false);
- cin.tie(NULL); cout.tie(NULL);
- cin >> s;
- for(int i = 0; i < (int)s.size(); ++i)
- a[s[i] - '0'].push_back(i);
- ll s1 = 0, t1 = 0, s2 = 0, t2 = 0;
- for(int i = 0; i < 2; ++i) {
- if((int) a[i].size() < 2) continue;
- if(a[i].back() - a[i].front() > t2 - s1) {
- s1 = a[i].front();
- t1 = a[i].back() - 1;
- s2 = a[i].front() + 1;
- t2 = a[i].back();
- }
- }
- cout << s1 + 1 << ' ' << t1 + 1 << ' ' << s2 + 1 << ' ' << t2 + 1;
- return 0;
- }
Add Comment
Please, Sign In to add comment