Submission #370504

#TimeUsernameProblemLanguageResultExecution timeMemory
370504ijxjdjdCrayfish scrivener (IOI12_scrivener)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define FR(i, N) for (int i = 0; i < int(N); i++) #define all(x) begin(x), end(x) using namespace std; using ll = long long; const int MAXN = (int)(1e6) + 5; const int MAXK = 21; int up[MAXN][MAXK]; int undo[MAXN][MAXK]; int depth[MAXN]; char res[MAXN]; int cnt = 1; int liftUp(int u, int d) { for (int i = 0; i < MAXK; i++) { if (d&(1<<i)) { u = up[u][i]; } } return u; } int liftUndo(int u, int d) { for (int i = 0; i < MAXK; i++) { if (d&(1<<i)) { u = undo[u][i]; } } return u; } void Init() { } void TypeLetter(char L) { res[cnt] = L; up[cnt][0] = cnt-1; undo[cnt][0] = cnt-1; for (int i = 1; i < MAXK; i++) { up[cnt][i] = up[up[cnt][i-1]][i-1]; undo[cnt][i] = undo[undo[cnt][i-1]][i-1]; } depth[cnt] = depth[cnt-1]+1; cnt++; } void UndoCommands(int U) { int next = liftUndo(cnt-1, U); res[cnt] = res[next]; up[cnt][0] = up[next][0]; undo[cnt][0] = cnt-1; for (int i = 1; i < MAXK; i++) { up[cnt][i] = up[up[cnt][i-1]][i-1]; undo[cnt][i] = undo[undo[cnt][i-1]][i-1]; } depth[cnt] = depth[next]; } char GetLetter(int P) { return res[liftUp(cnt-1, depth[cnt-1] - P - 1)]; } int main() { Init(); int cmd_num, tmp; tmp = scanf("%d", &cmd_num); int i; for (i = 0; i < cmd_num; i++) { char cmd; int tmp = scanf(" %c", &cmd); if (cmd == 'T') { char letter; tmp = scanf(" %c", &letter); TypeLetter(letter); } else if (cmd == 'U') { int number; tmp = scanf("%d", &number); UndoCommands(number); } else if (cmd == 'P') { int index; char letter; tmp = scanf("%d", &index); letter = GetLetter(index); printf("%c\n", letter); } } puts("Let's test for cheating!!"); return 0; }

Compilation message (stderr)

scrivener.cpp: In function 'int main()':
scrivener.cpp:72:9: warning: variable 'tmp' set but not used [-Wunused-but-set-variable]
   72 |     int tmp = scanf(" %c", &cmd);
      |         ^~~
scrivener.cpp:66:16: warning: variable 'tmp' set but not used [-Wunused-but-set-variable]
   66 |   int cmd_num, tmp;
      |                ^~~
/tmp/ccbQRitC.o: In function `main':
scrivener.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/cciC7RMu.o:grader.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status