Submission #117488

#TimeUsernameProblemLanguageResultExecution timeMemory
117488someone_aaCrayfish scrivener (IOI12_scrivener)C++17
0 / 100
232 ms64376 KiB
#include <bits/stdc++.h> #define ll long long #define pb push_back #define mp make_pair #define pii pair<int,int> using namespace std; const int N = (1<<20); const int LOGN = 20; char q_type[N]; char last[N]; int len[N], q, position; int point[N][LOGN]; char type, letter; int _time, cekori; int moment; void Init() { _time = 1; moment = 1; } void TypeLetter(char letter) { //cin>>letter; q_type[_time] = type; len[_time] = len[_time-1] + 1; last[_time] = letter; if(q_type[_time-1] == 'T') point[_time][0] = _time-1; else if(q_type[_time-1] == 'U') point[_time][0] = point[_time-1][0]; for(int i=1;i<20;i++) { point[_time][i] = point[point[_time][i-1]][i-1]; } /*cout<<len[_time]<<" "<<last[_time]<<" Pointers: \n"; for(int i=0;i<20;i++) { cout<<(1<<i)<<" th-parent: "<<point[_time][i]<<"\n"; }*/ _time++; } void UndoCommands(int cekori) { q_type[_time] = type; len[_time] = len[_time-cekori-1]; last[_time] = last[_time-cekori-1]; if(q_type[_time-cekori-1] == 'T') point[_time][0] = _time-cekori-1; else if(q_type[_time-cekori-1] == 'U') point[_time][0] = point[_time-cekori-1][0]; for(int i=1;i<20;i++) { point[_time][i] = point[point[_time][i-1]][i-1]; } //cout<<len[_time]<<" "<<point[_time]<<" "<<last[_time]<<"\n"; /*cout<<len[_time]<<" "<<last[_time]<<" Pointers: \n"; for(int i=0;i<20;i++) { cout<<(1<<i)<<" th-parent: "<<point[_time][i]<<"\n"; }*/ _time++; } char GetLetter(int position) { int ttime = _time - 1; //cout<<"Query: "; int temp = len[ttime] - position ; int c = ttime; if(q_type[c] == 'U') c = point[c][0]; int left_path = temp; //cout<<temp<<"\n"; int sum = 0; for(int i=19;i>=0;i--) { //cout<<c<<" -> "<<left_path<<"\n"; if(point[c][i] != 0 && left_path - (1<<i) >0 ){ c = point[c][i]; left_path -= (1<<i); } } //cout<<c<<"\n"; return last[c]; }

Compilation message (stderr)

scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:72:9: warning: unused variable 'sum' [-Wunused-variable]
     int sum = 0;
         ^~~
#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...