Submission #260234

#TimeUsernameProblemLanguageResultExecution timeMemory
260234youssefbou62크레이피쉬 글쓰는 기계 (IOI12_scrivener)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h>

#define push_back pb

using namespace std ; 

const int MAXN = 1e6+6 ; 

int state , cnt , par[MAXN][20]; 
map<int,string> ; 
void Init() {

}

void new_state(int s){
	for(int i=1;i<19;i++){
		par[s][i] = par[par[s][i-1]][i-1]; 
	}
  cerr << "current answer: " << ans[state] << endl; 
}

int kth_anc(int u,int k){
	for(int i = 18 ; i >= 0 ; i-- ){
		if(k&(1<<i)){
			k-=(1<<i); 
			u = par[u][i] ; 
		}
	}
	return u; 
}
void TypeLetter(char L) {

  ans[cnt] = ans[state]+L; 
  par[cnt][0] = state ; 
  state = cnt ;
  cnt ++ ; 
new_state(state); 
}

void UndoCommands(int U) {
	int u = kth_anc(state,U) ; 
	// for(int k = 0 ; k < U ; k++ ){
	// 	u = par[u] ; 
	// }
	par[cnt][0] = state ; 
	
	state = cnt ; 
	ans[state] = ans[u] ; 
	cnt ++ ;  
	new_state(state);
}

char GetLetter(int P) {

  return ans[state][P];

}


// int main() {
//   Init();

//   int cmd_num;
//   bool tmp = scanf("%d", &cmd_num);
//   assert(tmp == 1);

//   int i;
//   for (i = 0; i < cmd_num; i++) {
//     char cmd;
//     tmp = scanf(" %c", &cmd);
//     assert(tmp == 1);
//     if (cmd == 'T') {
//       char letter;
//       tmp = scanf(" %c", &letter);
//       assert(tmp == 1);
//       TypeLetter(letter);
//     }
//     else if (cmd == 'U') {
//       int number;
//       tmp = scanf("%d", &number);
//       assert(tmp == 1);
//       UndoCommands(number);
//     }
//     else if (cmd == 'P') {
//       int index;
//       char letter;
//       tmp = scanf("%d", &index);
//       assert(tmp == 1);
//       letter = GetLetter(index);
//       printf("%c\n", letter);
//     }
//   }
  
//   puts("Let's test for cheating!!");

//   return 0;

// }

Compilation message (stderr)

scrivener.cpp:10:1: error: declaration does not declare anything [-fpermissive]
 map<int,string> ; 
 ^~~~~~~~~~~~~~~
scrivener.cpp: In function 'void new_state(int)':
scrivener.cpp:19:33: error: 'ans' was not declared in this scope
   cerr << "current answer: " << ans[state] << endl; 
                                 ^~~
scrivener.cpp:19:33: note: suggested alternative: 'abs'
   cerr << "current answer: " << ans[state] << endl; 
                                 ^~~
                                 abs
scrivener.cpp: In function 'void TypeLetter(char)':
scrivener.cpp:33:3: error: 'ans' was not declared in this scope
   ans[cnt] = ans[state]+L; 
   ^~~
scrivener.cpp:33:3: note: suggested alternative: 'abs'
   ans[cnt] = ans[state]+L; 
   ^~~
   abs
scrivener.cpp: In function 'void UndoCommands(int)':
scrivener.cpp:48:2: error: 'ans' was not declared in this scope
  ans[state] = ans[u] ; 
  ^~~
scrivener.cpp:48:2: note: suggested alternative: 'abs'
  ans[state] = ans[u] ; 
  ^~~
  abs
scrivener.cpp: In function 'char GetLetter(int)':
scrivener.cpp:55:10: error: 'ans' was not declared in this scope
   return ans[state][P];
          ^~~
scrivener.cpp:55:10: note: suggested alternative: 'abs'
   return ans[state][P];
          ^~~
          abs