Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* e148 */
- /* AC (57ms, 2.2MB) */
- #include <iostream>
- #include <string>
- using namespace std;
- int T, ans;
- string s;
- int main()
- {
- ios::sync_with_stdio(false);
- cin.tie(0), cout.tie(0);
- cin >> T;
- while (T--)
- {
- cin >> s;
- s.push_back('z' + 1);
- ans = 0;
- for (int i = 1; i < s.size() - 1;)
- {
- int l = 0;
- while (s[ans + l] == s[i + l]) ++l;
- if (s[ans + l] > s[i + l]) swap(ans, i);
- i += l + 1;
- if (i == ans) ++i;
- }
- cout << ans + 1 << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement