Submission #70821

#TimeUsernameProblemLanguageResultExecution timeMemory
70821MANcityCrayfish scrivener (IOI12_scrivener)C++14
34 / 100
1096 ms119460 KiB
#include<iostream> #include<cstdio> #include<fstream> #include<algorithm> #include<cmath> #include<map> #include<queue> #include<set> #include<stack> #include<string> #include<cstring> #include<vector> using namespace std; #define for1(i,n) for(int i=1;i<=(int)n;i++) #define for0(i,n) for(int i=0;i<=(int)n;i++) #define forn(i,n) for(int i=n;i>=1;i--) #define fo(i,x,y) for(int i=x;i<=(int)y;i++) #define fr(i,x,y) for(int i=x;i>=(int)y;i--) #define pb push_back #define mp make_pair #define LL long long const LL Mod=1000*1000*1000+7; char last; int OP_NOW; int letter_par[1000002]; int up[1000002][30]; int height[1000002]; int maxhi=0; void Init() {} void TypeLetter(char L) { OP_NOW++; letter_par[OP_NOW]=(L-'a'); height[OP_NOW]=height[OP_NOW-1]+1; maxhi=max(maxhi,height[OP_NOW]); up[OP_NOW][0]=(OP_NOW-1); int G=log2(4*maxhi); for1(i,G) up[OP_NOW][i]=up[up[OP_NOW][i-1]][i-1]; } void UndoCommands(int U) { OP_NOW++; height[OP_NOW]=height[OP_NOW-U-1]; letter_par[OP_NOW]=letter_par[OP_NOW-U-1]; int G=log2(4*maxhi); for0(i,G) up[OP_NOW][i]=up[OP_NOW-U-1][i]; } char GetLetter(int P) { int N=height[OP_NOW]; if((P+1)==height[OP_NOW]) { return (letter_par[OP_NOW]+'a'); } int pos=OP_NOW; //cout<<pos<<" "<<up[pos][0]<<" "<<up[pos][1]<<" "<<up[pos][2]<<" "<<up[pos][3]<<endl; int G=log2(4*maxhi); fr(i,G,0) { //cout<<up[pos][i]<<" "<<height[up[pos][i]]<<endl; if(height[up[pos][i]]>=(P+1)) { //cout<<i<<"dddd"<<endl; pos=up[pos][i]; } } return (letter_par[pos]+'a'); } /* 1000 T a T b T d P 1 */

Compilation message (stderr)

scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:52:9: warning: unused variable 'N' [-Wunused-variable]
     int N=height[OP_NOW];
         ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...