Submission #66541549


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

using ll=long long;
using vl=vector<ll>;
#define all(c) begin(c),end(c)
#define pb push_back
#define sz(c) ll((c).size())

void solve(){
	ll n; cin >> n;
	string s; cin >> s;
	
	ll i=0;
	char c=' ';
	for(;i<n-1;i++) {
		if(s[i] <= s[i+1]) continue;
		
		cout << s.substr(0,i);
		c = s[i];
		break;
	}
	
	
	if(c == ' ') cout << s;
	else {
		for(ll j=i+1;j<n;j++) {
			if(c < s[j]) {
				cout << c;
				c = 'z'+1;
			}
			cout << s[j];
		}
		if(c != 'z'+1) cout << c;
	}
	
	cout << '\n';
	
	
}

int main() { cin.sync_with_stdio(0); cin.tie(0);
	
	
	ll t=1; cin >> t;
	while(t--) solve();
}

Submission Info

Submission Time
Task D - String Rotation
User qusol
Language C++ 20 (gcc 12.2)
Score 400
Code Size 682 Byte
Status AC
Exec Time 4 ms
Memory 3684 KiB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 1
AC × 18
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 4 ms 3368 KiB
01_test_02.txt AC 4 ms 3512 KiB
01_test_03.txt AC 4 ms 3412 KiB
01_test_04.txt AC 4 ms 3444 KiB
01_test_05.txt AC 2 ms 3516 KiB
01_test_06.txt AC 2 ms 3596 KiB
01_test_07.txt AC 2 ms 3544 KiB
01_test_08.txt AC 2 ms 3600 KiB
01_test_09.txt AC 1 ms 3600 KiB
01_test_10.txt AC 2 ms 3600 KiB
01_test_11.txt AC 2 ms 3600 KiB
01_test_12.txt AC 2 ms 3552 KiB
01_test_13.txt AC 2 ms 3632 KiB
01_test_14.txt AC 2 ms 3488 KiB
01_test_15.txt AC 2 ms 3560 KiB
01_test_16.txt AC 1 ms 3684 KiB
01_test_17.txt AC 2 ms 3412 KiB