Submission #66563317
Source Code Expand
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#include <atcoder/all>
using namespace atcoder;
int main(){
int T; cin >> T;
for(int i = 0; i < T; i++){
int N; string S, U = "";
cin >> N >> S;
int l = 0, r = 0;
bool f = false;
for(int j = 0; j < N - 1; j++){
char c = S[j];
if(c > S[j + 1]){
l = j, r = j + 1;
while(r < N - 1 && c >= S[r + 1])r++;
f = true;
break;
}
U += S[j];
}
if(!f){
cout << S << endl;
continue;
}
for(int j = l; j < r; j++)U += S[j + 1];
U += S[l];
for(int j = r + 1; j < N; j++)U += S[j];
cout << U << endl;
}
}
Submission Info
| Submission Time | |
|---|---|
| Task | D - String Rotation |
| User | iphi7 |
| Language | C++ 23 (gcc 12.2) |
| Score | 400 |
| Code Size | 832 Byte |
| Status | AC |
| Exec Time | 24 ms |
| Memory | 3716 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 400 / 400 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_01.txt |
| All | 00_sample_01.txt, 01_test_01.txt, 01_test_02.txt, 01_test_03.txt, 01_test_04.txt, 01_test_05.txt, 01_test_06.txt, 01_test_07.txt, 01_test_08.txt, 01_test_09.txt, 01_test_10.txt, 01_test_11.txt, 01_test_12.txt, 01_test_13.txt, 01_test_14.txt, 01_test_15.txt, 01_test_16.txt, 01_test_17.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_01.txt | AC | 1 ms | 3572 KiB |
| 01_test_01.txt | AC | 24 ms | 3504 KiB |
| 01_test_02.txt | AC | 24 ms | 3524 KiB |
| 01_test_03.txt | AC | 24 ms | 3572 KiB |
| 01_test_04.txt | AC | 24 ms | 3504 KiB |
| 01_test_05.txt | AC | 3 ms | 3644 KiB |
| 01_test_06.txt | AC | 3 ms | 3648 KiB |
| 01_test_07.txt | AC | 3 ms | 3480 KiB |
| 01_test_08.txt | AC | 3 ms | 3648 KiB |
| 01_test_09.txt | AC | 2 ms | 3668 KiB |
| 01_test_10.txt | AC | 2 ms | 3700 KiB |
| 01_test_11.txt | AC | 3 ms | 3632 KiB |
| 01_test_12.txt | AC | 3 ms | 3696 KiB |
| 01_test_13.txt | AC | 3 ms | 3704 KiB |
| 01_test_14.txt | AC | 3 ms | 3640 KiB |
| 01_test_15.txt | AC | 3 ms | 3712 KiB |
| 01_test_16.txt | AC | 3 ms | 3716 KiB |
| 01_test_17.txt | AC | 7 ms | 3504 KiB |