DuongNhi99

TOURS

Nov 30th, 2020
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.81 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4.  
  5. string s;
  6. vector<ll> a[3];
  7.  
  8. int main()
  9. {
  10.     //freopen("in.txt", "r", stdin);
  11.     freopen("TOURS.inp", "r", stdin);
  12.     freopen("TOURS.out", "w", stdout);
  13.     ios_base::sync_with_stdio(false);
  14.     cin.tie(NULL); cout.tie(NULL);
  15.  
  16.     cin >> s;
  17.  
  18.     for(int i = 0; i < (int)s.size(); ++i)
  19.         a[s[i] - '0'].push_back(i);
  20.  
  21.     ll s1 = 0, t1 = 0, s2 = 0, t2 = 0;
  22.  
  23.     for(int i = 0; i < 2; ++i) {
  24.         if((int) a[i].size() < 2) continue;
  25.  
  26.         if(a[i].back() - a[i].front() > t2 - s1) {
  27.             s1 = a[i].front();
  28.             t1 = a[i].back() - 1;
  29.             s2 = a[i].front() + 1;
  30.             t2 = a[i].back();
  31.         }
  32.     }
  33.  
  34.     cout << s1 + 1 << ' ' << t1 + 1 << ' ' << s2 + 1 << ' ' << t2 + 1;
  35.  
  36.     return 0;
  37. }
  38.  
Add Comment
Please, Sign In to add comment