제출 #414127

#제출 시각아이디문제언어결과실행 시간메모리
414127blue크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++17
컴파일 에러
0 ms0 KiB
#include <vector> #include <iostream> using namespace std; int mx = 1'000'000; int lg_mx = 20; int curr; int len[1+mx]; char last[1+mx]; int letter_anc[1+mx][lg_mx]; int undo_anc[1+mx][lg_mx]; int lg2[1+mx]; void Init() { lg2[0] = -1; lg2[1] = 0; for(int i = 2; i <= mx; i++) lg2[i] = lg2[i/2] + 1; curr = 0; len[0] = -1; last[0] = '?'; for(int e = 0; e < lg_mx; e++) letter_anc[0][e] = undo_anc[0][e] = 0; } void TypeLetter(char L) { curr++; len[curr] = len[curr-1] + 1; last[curr] = L; letter_anc[curr][0] = curr-1; undo_anc[curr][0] = curr-1; for(int e = 1; e < max(lg2[curr], lg2[len[curr]])+2; e++) { letter_anc[curr][e] = letter_anc[ letter_anc[curr][e-1] ][e-1]; undo_anc[curr][e] = undo_anc[ undo_anc[curr][e-1] ][e-1]; } // cerr << curr << '\n'; } void UndoCommands(int U) { int prev = curr; for(int e = 0; e < lg2[curr]+2; e++) { if(U & (1 << e)) prev = undo_anc[prev][e]; } // cerr << "making copy of " << prev << '\n'; curr++; len[curr] = len[prev]; last[curr] = last[prev]; letter_anc[curr][0] = letter_anc[prev][0]; undo_anc[curr][0] = curr-1; for(int e = 1; e < max(lg2[curr], lg2[len[curr]])+2; e++) { letter_anc[curr][e] = letter_anc[ letter_anc[curr][e-1] ][e-1]; undo_anc[curr][e] = undo_anc[ undo_anc[curr][e-1] ][e-1]; } // cerr << curr << '\n'; } char GetLetter(int P) { int pos = curr; for(int e = max(lg2[curr], lg2[len[curr]])+2; e >= 0; e--) if(len[ letter_anc[pos][e] ] >= P) pos = letter_anc[pos][e]; return last[pos]; }

컴파일 시 표준 에러 (stderr) 메시지

scrivener.cpp:9:13: error: array bound is not an integer constant before ']' token
    9 | int len[1+mx];
      |             ^
scrivener.cpp:10:15: error: array bound is not an integer constant before ']' token
   10 | char last[1+mx];
      |               ^
scrivener.cpp:11:20: error: array bound is not an integer constant before ']' token
   11 | int letter_anc[1+mx][lg_mx];
      |                    ^
scrivener.cpp:11:27: error: array bound is not an integer constant before ']' token
   11 | int letter_anc[1+mx][lg_mx];
      |                           ^
scrivener.cpp:12:18: error: array bound is not an integer constant before ']' token
   12 | int undo_anc[1+mx][lg_mx];
      |                  ^
scrivener.cpp:12:25: error: array bound is not an integer constant before ']' token
   12 | int undo_anc[1+mx][lg_mx];
      |                         ^
scrivener.cpp:13:13: error: array bound is not an integer constant before ']' token
   13 | int lg2[1+mx];
      |             ^
scrivener.cpp: In function 'void Init()':
scrivener.cpp:17:5: error: 'lg2' was not declared in this scope
   17 |     lg2[0] = -1;
      |     ^~~
scrivener.cpp:24:5: error: 'len' was not declared in this scope; did you mean 'mblen'?
   24 |     len[0] = -1;
      |     ^~~
      |     mblen
scrivener.cpp:25:5: error: 'last' was not declared in this scope
   25 |     last[0] = '?';
      |     ^~~~
scrivener.cpp:27:9: error: 'letter_anc' was not declared in this scope
   27 |         letter_anc[0][e] = undo_anc[0][e] = 0;
      |         ^~~~~~~~~~
scrivener.cpp:27:28: error: 'undo_anc' was not declared in this scope
   27 |         letter_anc[0][e] = undo_anc[0][e] = 0;
      |                            ^~~~~~~~
scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:33:5: error: 'len' was not declared in this scope; did you mean 'mblen'?
   33 |     len[curr] = len[curr-1] + 1;
      |     ^~~
      |     mblen
scrivener.cpp:34:5: error: 'last' was not declared in this scope
   34 |     last[curr] = L;
      |     ^~~~
scrivener.cpp:36:5: error: 'letter_anc' was not declared in this scope
   36 |     letter_anc[curr][0] = curr-1;
      |     ^~~~~~~~~~
scrivener.cpp:37:5: error: 'undo_anc' was not declared in this scope
   37 |     undo_anc[curr][0] = curr-1;
      |     ^~~~~~~~
scrivener.cpp:38:28: error: 'lg2' was not declared in this scope
   38 |     for(int e = 1; e < max(lg2[curr], lg2[len[curr]])+2; e++)
      |                            ^~~
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:50:24: error: 'lg2' was not declared in this scope
   50 |     for(int e = 0; e < lg2[curr]+2; e++)
      |                        ^~~
scrivener.cpp:53:20: error: 'undo_anc' was not declared in this scope
   53 |             prev = undo_anc[prev][e];
      |                    ^~~~~~~~
scrivener.cpp:59:5: error: 'len' was not declared in this scope; did you mean 'mblen'?
   59 |     len[curr] = len[prev];
      |     ^~~
      |     mblen
scrivener.cpp:60:5: error: 'last' was not declared in this scope
   60 |     last[curr] = last[prev];
      |     ^~~~
scrivener.cpp:62:5: error: 'letter_anc' was not declared in this scope
   62 |     letter_anc[curr][0] = letter_anc[prev][0];
      |     ^~~~~~~~~~
scrivener.cpp:63:5: error: 'undo_anc' was not declared in this scope
   63 |     undo_anc[curr][0] = curr-1;
      |     ^~~~~~~~
scrivener.cpp:65:28: error: 'lg2' was not declared in this scope
   65 |     for(int e = 1; e < max(lg2[curr], lg2[len[curr]])+2; e++)
      |                            ^~~
scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:77:21: error: 'lg2' was not declared in this scope
   77 |     for(int e = max(lg2[curr], lg2[len[curr]])+2; e >= 0; e--)
      |                     ^~~
scrivener.cpp:77:36: error: 'len' was not declared in this scope; did you mean 'mblen'?
   77 |     for(int e = max(lg2[curr], lg2[len[curr]])+2; e >= 0; e--)
      |                                    ^~~
      |                                    mblen
scrivener.cpp:78:17: error: 'letter_anc' was not declared in this scope
   78 |         if(len[ letter_anc[pos][e] ] >= P)
      |                 ^~~~~~~~~~
scrivener.cpp:81:12: error: 'last' was not declared in this scope
   81 |     return last[pos];
      |            ^~~~