Submission #302865

#TimeUsernameProblemLanguageResultExecution timeMemory
302865HeheheCrayfish scrivener (IOI12_scrivener)C++14
100 / 100
721 ms116728 KiB
#include<bits/stdc++.h> //:3 using namespace std; typedef long long ll; #define all(a) (a).begin(), (a).end() #define ff first #define ss second #define pb push_back #define mp make_pair #define pi pair<int, int> #define sz(x) (int)((x).size()) //#define int long long const int dx[] = {0, 1, 0, -1}; const int dy[] = {1, 0, -1, 0}; const ll inf = 2e9; const ll mod = 1e9 + 7; const int N = 1e6 + 11; const ll INF64 = 3e18 + 1; const double eps = 1e-14; const double PI = acos(-1); //ifstream in(".in"); //ofstream out(".out"); int v[N], tip[N], p[N], lvl[N], dp[N][25], k; void Init(){}; void TypeLetter(char L){ int nod = v[k]; v[++k] = k; tip[k] = L - 'a'; if(tip[nod] == -1){ p[k] = p[nod]; }else{ p[k] = nod; } lvl[k] = lvl[p[k]] + 1; dp[k][0] = p[k]; for(int i = 1; i <= 20; i++){ dp[k][i] = dp[dp[k][i - 1]][i - 1]; } } void UndoCommands(int U){ int nod = v[k - U]; v[++k] = k; tip[k] = -1; if(tip[nod] == -1){ p[k] = p[nod]; }else{ p[k] = nod; } } char GetLetter(int P){ int nod = v[k]; if(tip[nod] == -1)nod = p[nod]; int len = lvl[nod] - P - 1; for(int i = 20; i >= 0; i--){ if((1 << i) <= len){ nod = dp[nod][i]; len -= (1 << i); } } return (char)(tip[nod] + 'a'); }

Compilation message (stderr)

scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:33:7: warning: operation on 'k' may be undefined [-Wsequence-point]
   33 |     v[++k] = k;
      |       ^~~
scrivener.cpp:33:7: warning: operation on 'k' may be undefined [-Wsequence-point]
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:54:7: warning: operation on 'k' may be undefined [-Wsequence-point]
   54 |     v[++k] = k;
      |       ^~~
scrivener.cpp:54:7: warning: operation on 'k' may be undefined [-Wsequence-point]
#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...