fork(2) 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. priority_queue<string,vector<string>,greater<string>> pq;
  11. for(int i=0;i<N;i++){
  12. temp=temp.substr(1)+temp[0];
  13. pq.push(temp);
  14. }
  15. cout << pq.top() << '\n';
  16. }
Success #stdin #stdout 0.01s 5316KB
stdin
1
1000
stdout
0001