Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define task "CAU3"
- #include <iostream>
- #include <cstdio>
- #include <algorithm>
- using namespace std;
- constexpr int N = 1e2 + 5;
- int k;
- string x, s[N];
- void Read()
- {
- cin >> k >> x;
- }
- void Solve()
- {
- for (int i = 0; i < (int)x.size(); ++i)
- {
- rotate(x.begin(), x.begin() + 1, x.end());
- s[i] = x;
- }
- sort(s, s + x.size());
- int m = unique(s, s + x.size()) - s;
- if (k > m)
- cout << -1;
- else
- cout << s[k - 1];
- }
- int32_t main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- if (fopen(task ".INP", "r"))
- {
- freopen(task ".INP", "r", stdin);
- freopen(task ".OUT", "w", stdout);
- }
- Read();
- Solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement