Submission #885605

#TimeUsernameProblemLanguageResultExecution timeMemory
885605GlaucoCrayfish scrivener (IOI12_scrivener)C++17
34 / 100
528 ms262144 KiB
#include <bits/stdc++.h> using namespace std; int idx = 1, curr = 0; struct node{ char c; vector<int> hist, str; int size; }; vector<node> v(3e6); void Init(){ v[0].c = '0'; v[0].size = 0; } void TypeLetter(char l){ v[idx].c = l; v[idx].size = v[curr].size+1; v[idx].str.push_back(curr); for(int i = 1; 1; i++){ if(i-1 >= v[v[idx].str[i-1]].str.size()) break; v[idx].str.push_back(v[v[idx].str[i-1]].str[i-1]); } v[idx].hist.push_back(curr); for(int i = 1; 1; i++){ if(i-1 >= v[v[idx].hist[i-1]].hist.size()) break; v[idx].hist.push_back(v[v[idx].hist[i-1]].hist[i-1]); } curr = idx; idx++; } void UndoCommands(int u){ int l = log2(idx)+3; int temp = curr; for(int i = l; i >= 0; i--){ if((u & (1<<i)) && v[temp].hist.size() > i) temp = v[temp].hist[i]; } v[idx] = v[temp]; v[idx].hist[0] = curr; for(int i = 1; 1; i++){ if(i-1 >= v[v[idx].hist[i-1]].hist.size()) break; if(i < v[idx].hist.size()) v[idx].hist[i] = v[v[idx].hist[i-1]].hist[i-1]; else v[idx].hist.push_back(v[v[idx].hist[i-1]].hist[i-1]); } curr = idx; idx++; } char GetLetter(int p){ int l = log2(idx)+3; p = v[curr].size-p-1; int temp = curr; for(int i = l; i >= 0; i--){ if((p & (1<<i)) && v[temp].str.size() > i) temp = v[temp].str[i]; } return v[temp].c; }

Compilation message (stderr)

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:23:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     if(i-1 >= v[v[idx].str[i-1]].str.size()) break;
      |        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scrivener.cpp:29:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |     if(i-1 >= v[v[idx].hist[i-1]].hist.size()) break;
      |        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:41:44: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   41 |     if((u & (1<<i)) && v[temp].hist.size() > i) temp = v[temp].hist[i];
      |                        ~~~~~~~~~~~~~~~~~~~~^~~
scrivener.cpp:47:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     if(i-1 >= v[v[idx].hist[i-1]].hist.size()) break;
      |        ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
scrivener.cpp:49:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   49 |     if(i < v[idx].hist.size()) v[idx].hist[i] = v[v[idx].hist[i-1]].hist[i-1];
      |        ~~^~~~~~~~~~~~~~~~~~~~
scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:60:43: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   60 |     if((p & (1<<i)) && v[temp].str.size() > i) temp = v[temp].str[i];
      |                        ~~~~~~~~~~~~~~~~~~~^~~
#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...