Submission #1186875
Source Code Expand
#define DEB #include<bits/stdc++.h> #define REP(i,m) for(int i=0;i<(m);++i) #define REPN(i,m,in) for(int i=(in);i<(m);++i) #define ALL(t) (t).begin(),(t).end() #define CLR(a) memset((a),0,sizeof(a)) #define pb push_back #define mp make_pair #define fr first #define sc second using namespace std; #ifdef DEB #define dump(x) cerr << #x << " = " << (x) << endl #define prl cerr<<"called:"<< __LINE__<<endl #define dumpR(x) cerr<<"\x1b[31m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl #define dumpY(x) cerr<<"\x1b[33m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl #define dumpG(x) cerr<<"\x1b[32m"<<#x<<" = " <<(x)<<"\x1b[39m"<<endl template<class T> void debug(T a,T b){ for(;a!=b;++a) cerr<<*a<<' ';cerr<<endl;} #else #define dump(x) ; #define dumpR(x) ; #define dumpY(x) ; #define dumpG(x) ; #define prl ; template<class T> void debug(T a,T b){ ;} #endif template<class T> void chmin(T& a,const T& b) { if(a>b) a=b; } template<class T> void chmax(T& a,const T& b) { if(a<b) a=b; } typedef long long int lint; typedef pair<int,int> pi; namespace std{ template<class S,class T> ostream &operator <<(ostream& out,const pair<S,T>& a){ out<<'('<<a.fr<<','<<a.sc<<')'; return out; } } //const int INF=5e8; int n,K; char s[200005]; int ar[200005]; char ans[200005]; int main(){ scanf("%d%d",&n,&K); scanf("%s",s); n=strlen(s); REP(i,n) ar[i]=(s[i]-'A'); int off=0,flip=0; bool ok=false; REP(i,K){ if(off>=n){ REP(j,n) ans[j]='A'+((n-j-1)&1); if(n&1 && (K-1)&1){ ans[0]='B'; } ok=true; break; } if((ar[off]^flip)==0){ ar[off]^=1; }else{ ++off; flip^=1; } } if(!ok){ REP(i,off) ans[n-1-i]='A'+(i&1); REP(i,n-off) ans[i]=(ar[off+i]^flip)+'A'; } printf("%s\n",ans); return 0; }
Submission Info
Submission Time | |
---|---|
Task | D - Half Reflector |
User | hogloid |
Language | C++14 (GCC 5.4.1) |
Score | 900 |
Code Size | 1869 Byte |
Status | AC |
Exec Time | 4 ms |
Memory | 1664 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:52:22: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&n,&K); ^ ./Main.cpp:53:16: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%s",s); ^
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 900 / 900 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | sample1.txt, sample2.txt, sample3.txt |
All | sample1.txt, sample2.txt, sample3.txt, in1.txt, in10.txt, in11.txt, in12.txt, in13.txt, in14.txt, in15.txt, in16.txt, in17.txt, in18.txt, in19.txt, in2.txt, in20.txt, in21.txt, in22.txt, in23.txt, in24.txt, in25.txt, in26.txt, in27.txt, in28.txt, in29.txt, in3.txt, in30.txt, in31.txt, in32.txt, in33.txt, in34.txt, in35.txt, in36.txt, in37.txt, in38.txt, in39.txt, in4.txt, in40.txt, in41.txt, in42.txt, in5.txt, in543.txt, in557.txt, in6.txt, in7.txt, in8.txt, in9.txt, sample1.txt, sample2.txt, sample3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
in1.txt | AC | 1 ms | 256 KB |
in10.txt | AC | 3 ms | 1664 KB |
in11.txt | AC | 4 ms | 1664 KB |
in12.txt | AC | 3 ms | 1664 KB |
in13.txt | AC | 3 ms | 1664 KB |
in14.txt | AC | 4 ms | 1664 KB |
in15.txt | AC | 3 ms | 1664 KB |
in16.txt | AC | 3 ms | 1664 KB |
in17.txt | AC | 3 ms | 1664 KB |
in18.txt | AC | 3 ms | 1664 KB |
in19.txt | AC | 3 ms | 1664 KB |
in2.txt | AC | 2 ms | 896 KB |
in20.txt | AC | 3 ms | 1664 KB |
in21.txt | AC | 3 ms | 1664 KB |
in22.txt | AC | 4 ms | 1664 KB |
in23.txt | AC | 4 ms | 1664 KB |
in24.txt | AC | 4 ms | 1664 KB |
in25.txt | AC | 4 ms | 1664 KB |
in26.txt | AC | 4 ms | 1664 KB |
in27.txt | AC | 4 ms | 1664 KB |
in28.txt | AC | 3 ms | 1664 KB |
in29.txt | AC | 3 ms | 1664 KB |
in3.txt | AC | 3 ms | 1664 KB |
in30.txt | AC | 3 ms | 1664 KB |
in31.txt | AC | 3 ms | 1664 KB |
in32.txt | AC | 3 ms | 1664 KB |
in33.txt | AC | 3 ms | 1664 KB |
in34.txt | AC | 4 ms | 1664 KB |
in35.txt | AC | 4 ms | 1664 KB |
in36.txt | AC | 4 ms | 1664 KB |
in37.txt | AC | 4 ms | 1664 KB |
in38.txt | AC | 4 ms | 1664 KB |
in39.txt | AC | 3 ms | 1664 KB |
in4.txt | AC | 4 ms | 1664 KB |
in40.txt | AC | 3 ms | 1664 KB |
in41.txt | AC | 3 ms | 1664 KB |
in42.txt | AC | 3 ms | 1664 KB |
in5.txt | AC | 4 ms | 1664 KB |
in543.txt | AC | 3 ms | 1664 KB |
in557.txt | AC | 3 ms | 1664 KB |
in6.txt | AC | 1 ms | 256 KB |
in7.txt | AC | 3 ms | 1664 KB |
in8.txt | AC | 4 ms | 1664 KB |
in9.txt | AC | 3 ms | 1664 KB |
sample1.txt | AC | 1 ms | 256 KB |
sample2.txt | AC | 1 ms | 256 KB |
sample3.txt | AC | 1 ms | 256 KB |