fork(1) download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main() {
  5. int N;
  6. cin>>N;
  7. string str;
  8. cin >> str;
  9. string temp=str;
  10. vector<string> pq;
  11. for(int i=0;i<N;i++){
  12. temp=temp.substr(1)+temp[0];
  13. pq.push_back(temp);
  14. }
  15. sort(pq.begin(),pq.end());
  16. cout << pq[0] << '\n';
  17. }
Success #stdin #stdout 0.01s 5316KB
stdin
5
00010
stdout
00001