Submission #66623713


Source Code Expand

#include<bits/extc++.h>
using namespace std;
using namespace chrono;
using namespace __gnu_cxx;
using namespace __gnu_pbds;
#if 1
using ll=long long;
using uint=unsigned int;
using ull=unsigned long long;
using _Pi=pair<int,int>;
using _Vi=vector<int>;
using _Vpi=vector<_Pi>;
using db=double;
using ldb=long double;
#ifdef _INT128_DEFINED
using i128=__int128;
#endif
//#define ONLINE_JUDGE
//#define _INT_TO_LL
#define _CLOSE_SYNC
//#define _USE_FREOPEN
#if __cplusplus>=201103L
//#define _RAND_USE_Mt19937
#define _UM(_Key,_Type) unordered_map<_Key,_Type>
#define _US(_Type) unordered_set<_Type>
#define _UMM(_Key,_Type) unordered_multimap<_Key,_Type>
#define _UMS(_Type) unordered_multiset<_Type>
#define tostr(_Name) std::to_string(x)
#else
#define constexpr const
#endif
#define y0 __Y0_By_MySelf__
#define y1 __Y1_By_MySelf__
#define yn __Yn_By_MySelf__
#define _GPQ(_Type) priority_queue<_Type,vector<_Type>,greater<_Type>>
#define _SPQ(_Type,_Cmp) priority_queue<_Type,vector<_Type>,_Cmp>
#define _FPQ(_Type,_Cmp) priority_queue<_Type,vector<_Type>,decltype(&_Cmp)>
#define _PQ(_Type) priority_queue<_Type>
#define _MM(_Key,_Type) multimap<_Key,_Type>
#define _MS(_Type) multiset<_Type>
#define mem(_Num,_Arr) memset((_Arr),(_Num),sizeof(_Arr))
#define clr(_Arr) memset((_Arr),0,sizeof(_Arr))
#define neg(_Arr) memset((_Arr),-1,sizeof(_Arr))
#define fmax(_Arr) memset((_Arr),0x7f,sizeof(_Arr))
#define fmax_s(_Arr) memset((_Arr),0x3f,sizeof(_Arr))
#define fmin(_Arr) memset((_Arr),0x80,sizeof(_Arr))
#define fmin_s(_Arr) memset((_Arr),0xc0,sizeof(_Arr))
#define four_d(_Name) constexpr int _Name[4][2]={{0,1},{1,0},{0,-1},{-1,0}}
#define eight_d(_Name) constexpr int _Name[8][2]={{0,1},{1,1},{1,0},{1,-1},{0,-1},{-1,-1},{-1,0},{-1,1}};
#define _FF(_Name,_Begin,_End) for(auto _Name=(_Begin);_Name<(_End);_Name++)
#define _RF(_Name,_Begin,_End) for(auto _Name=(_Begin);_Name>(_End);_Name--)
#define _FE(_Name,_Container) for(auto _Name:_Container)
#ifndef ONLINE_JUDGE
#ifdef _CLOSE_SYNC
#define _p(_X,_F) (clog<<(_X)<<" \n"[_F])
#define _psth clog<<"\n--------------------"<<__LINE__<<"---------------------\n";
#define _pel clog<<'\n'
#else
#define _p(_X,_F) (cerr<<(_X)<<" \n"[_F])
#define _psth cerr<<"\n--------------------"<<__LINE__<<"---------------------\n";
#define _pel cerr<<'\n'
#endif
#else
#define _p(_X,_F)
#define _psth
#define _pel
#endif
#ifdef _INT_TO_LL
#define int long long
#endif
#ifdef _RAND_USE_Mt19937
mt19937_64 __Random_Number__(static_cast<unsigned>(duration_cast<milliseconds>(system_clock::now().time_since_epoch()).count()));
#ifdef _INT_TO_LL
uniform_int_distribution<ull> __Random_Dist__(0,LLONG_MAX);
#else
uniform_int_distribution<uint> __Random_Dist__(0,INT_MAX);
#endif
#define rand() __Random_Dist__(__Random_Number__)
#define srand(__X) __Random_Number__.seed(__X)
#endif
constexpr ull HashP=1313131313131313131ull,HashP1=1111111111111111171ull,HashP2=37093201209218101ull,HashP3=3113333333333333333ull,HashP4=4444444444444444409ull,HashP5=370903201209218177ull;
constexpr int mod3=998244353,mod7=1000000007,mod9=1000000009;
#endif
int t,l,p,i;
string s,tmp;
signed main(){
#ifdef _CLOSE_SYNC
	cin.tie(0)->sync_with_stdio(0);
	cout.tie(0);
#endif
#ifdef _USE_FREOPEN
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
	cin>>t;
	while(t--){
		cin>>l>>s;
		if(l==1){
			cout<<s<<'\n';
			continue;
		}
		i=0;
		for(;s[i]<=s[i+1]&&i<s.length();i++);
		for(;i<s.length()-1&&s[i]>=s[i+1];swap(s[i],s[i+1]),i++);
		cout<<s<<'\n';
	}
	return 0;
}

Submission Info

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

Compile Error

Main.cpp: In function ‘int main()’:
Main.cpp:103:37: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  103 |                 for(;s[i]<=s[i+1]&&i<s.length();i++);
      |                                    ~^~~~~~~~~~~
Main.cpp:104:23: warning: comparison of integer expressions of different signedness: ‘int’ and ‘std::__cxx11::basic_string<char>::size_type’ {aka ‘long unsigned int’} [-Wsign-compare]
  104 |                 for(;i<s.length()-1&&s[i]>=s[i+1];swap(s[i],s[i+1]),i++);
      |                      ~^~~~~~~~~~~~~

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 3388 KiB
01_test_01.txt AC 3 ms 3368 KiB
01_test_02.txt AC 3 ms 3476 KiB
01_test_03.txt AC 4 ms 3476 KiB
01_test_04.txt AC 3 ms 3404 KiB
01_test_05.txt AC 1 ms 3472 KiB
01_test_06.txt AC 1 ms 3480 KiB
01_test_07.txt AC 1 ms 3596 KiB
01_test_08.txt AC 1 ms 3476 KiB
01_test_09.txt AC 1 ms 3564 KiB
01_test_10.txt AC 1 ms 3708 KiB
01_test_11.txt AC 1 ms 3604 KiB
01_test_12.txt AC 1 ms 3712 KiB
01_test_13.txt AC 1 ms 3696 KiB
01_test_14.txt AC 1 ms 3516 KiB
01_test_15.txt AC 1 ms 3480 KiB
01_test_16.txt AC 1 ms 3524 KiB
01_test_17.txt AC 2 ms 3408 KiB