Submission #20811

#TimeUsernameProblemLanguageResultExecution timeMemory
20811jjwdi0Crayfish scrivener (IOI12_scrivener)C++11
100 / 100
933 ms96352 KiB
int par[1<<20][21], size[1<<20], for_undo[1<<20],  kth, Q;
char a[1<<20];
void Init(){}
void TypeLetter(char x) {
	for_undo[kth] = kth; if(kth) par[kth][0] = for_undo[kth - 1]; 
	for(int i = 1; par[kth][i-1]; i++) par[kth][i] = par[par[kth][i-1]][i-1];
	a[kth] = x, size[kth] = size[par[kth++][0]] + 1;
}
void UndoCommands(int x){ for_undo[kth] = for_undo[kth++ - x - 1]; }
char GetLetter(int x) {
	int u = for_undo[kth - 1];
	for(int i = 19; ~i; i--) if(size[par[u][i]] > x) u = par[u][i];
	return a[u];
}

Compilation message (stderr)

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:7:49: warning: operation on 'kth' may be undefined [-Wsequence-point]
  a[kth] = x, size[kth] = size[par[kth++][0]] + 1;
                                                 ^
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:9:66: warning: operation on 'kth' may be undefined [-Wsequence-point]
 void UndoCommands(int x){ for_undo[kth] = for_undo[kth++ - x - 1]; }
                                                                  ^
#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...