Submission #66545483
Source Code Expand
#include <bits/stdc++.h>
#define _F(x,y,z) for(int x=y;x<=z;x++)
#define F_(x,z,y) for(int x=z;x>=y;x--)
#define TF(x,y,z) for(int x=head[y],z;x;x=nex[x])
#define GF(x,y,z) for(int x:z[y])
using namespace std;
typedef long long ll;
typedef double dou;
typedef const int ci;
typedef pair<int,int> pii;
ci maxn=2e6+10;
int n,tg;
char s[maxn];
void work()
{
scanf("%d",&n);
tg=0;
scanf("%s",s+1);
_F(i,1,n-1)
{
if(s[i]>s[i+1])
swap(s[i],s[i+1]),tg=1;
else if(tg&&s[i]==s[i+1])
swap(s[i],s[i+1]);
else if(tg)
{
printf("%s\n",s+1);
return ;
}
}
if(tg||n==1)
printf("%s\n",s+1);
else
{
printf("%s\n",s+1);
}
return ;
}
int main()
{
int t;
scanf("%d",&t);
while(t--)
work();
return 0;
}
Submission Info
| Submission Time |
|
| Task |
D - String Rotation |
| User |
adolphshi |
| Language |
C++ 20 (gcc 12.2) |
| Score |
400 |
| Code Size |
775 Byte |
| Status |
AC |
| Exec Time |
4 ms |
| Memory |
3884 KiB |
Compile Error
Main.cpp: In function ‘void work()’:
Main.cpp:20:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
20 | scanf("%d",&n);
| ~~~~~^~~~~~~~~
Main.cpp:22:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
22 | scanf("%s",s+1);
| ~~~~~^~~~~~~~~~
Main.cpp: In function ‘int main()’:
Main.cpp:46:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
46 | scanf("%d",&t);
| ~~~~~^~~~~~~~~
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 |
3700 KiB |
| 01_test_01.txt |
AC |
4 ms |
3700 KiB |
| 01_test_02.txt |
AC |
4 ms |
3696 KiB |
| 01_test_03.txt |
AC |
4 ms |
3884 KiB |
| 01_test_04.txt |
AC |
4 ms |
3588 KiB |
| 01_test_05.txt |
AC |
2 ms |
3584 KiB |
| 01_test_06.txt |
AC |
2 ms |
3776 KiB |
| 01_test_07.txt |
AC |
1 ms |
3696 KiB |
| 01_test_08.txt |
AC |
1 ms |
3712 KiB |
| 01_test_09.txt |
AC |
1 ms |
3728 KiB |
| 01_test_10.txt |
AC |
1 ms |
3756 KiB |
| 01_test_11.txt |
AC |
1 ms |
3796 KiB |
| 01_test_12.txt |
AC |
1 ms |
3800 KiB |
| 01_test_13.txt |
AC |
1 ms |
3816 KiB |
| 01_test_14.txt |
AC |
1 ms |
3828 KiB |
| 01_test_15.txt |
AC |
2 ms |
3700 KiB |
| 01_test_16.txt |
AC |
2 ms |
3792 KiB |
| 01_test_17.txt |
AC |
2 ms |
3696 KiB |