제출 #336893

#제출 시각아이디문제언어결과실행 시간메모리
336893blue동굴 (IOI13_cave)C++11
컴파일 에러
0 ms0 KiB
#include "cave.h" #include <iostream> #include <vector> using namespace std; int S[N], D[N], Q[N]; //switch_state, switch_door, query void b_search(int door, int pos, int a, int b) { if(a == b) { D[a] = door; S[a] = pos; } else { m = (a+b)/2; for(int i = 0; i < N; i++) { if(S[i] != -1) Q[i] = S[i]; else { if(a <= i && i <= m) Q[i] = pos; else Q[i] = !pos; } } int q = tryCombination(Q); if(q == door) b_search(door, pos, m+1, b); else b_search(door, pos, a, m); } } void exploreCave(int N) { for(int i = 0; i < N; i++) S[i] = D[i] = -1; for(int door = 0; door < N; door++) { for(int i = 0; i < N; i++) { if(S[i] == -1) Q[i] = 0; else Q[i] = S[i]; } int q = tryCombination(Q); if(q == door) { //switch_pos of switch connected to door 1 = 1 b_search(door, 1, 0, N-1); } else { b_search(door, 0, 0, N-1); } } answer(S, D); }

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

cave.cpp:6:7: error: 'N' was not declared in this scope
    6 | int S[N], D[N], Q[N];
      |       ^
cave.cpp:6:13: error: 'N' was not declared in this scope
    6 | int S[N], D[N], Q[N];
      |             ^
cave.cpp:6:19: error: 'N' was not declared in this scope
    6 | int S[N], D[N], Q[N];
      |                   ^
cave.cpp: In function 'void b_search(int, int, int, int)':
cave.cpp:13:9: error: 'D' was not declared in this scope
   13 |         D[a] = door;
      |         ^
cave.cpp:14:9: error: 'S' was not declared in this scope
   14 |         S[a] = pos;
      |         ^
cave.cpp:18:9: error: 'm' was not declared in this scope
   18 |         m = (a+b)/2;
      |         ^
cave.cpp:19:28: error: 'N' was not declared in this scope
   19 |         for(int i = 0; i < N; i++)
      |                            ^
cave.cpp:21:16: error: 'S' was not declared in this scope
   21 |             if(S[i] != -1) Q[i] = S[i];
      |                ^
cave.cpp:21:28: error: 'Q' was not declared in this scope
   21 |             if(S[i] != -1) Q[i] = S[i];
      |                            ^
cave.cpp:24:38: error: 'Q' was not declared in this scope
   24 |                 if(a <= i && i <= m) Q[i] = pos;
      |                                      ^
cave.cpp:25:22: error: 'Q' was not declared in this scope
   25 |                 else Q[i] = !pos;
      |                      ^
cave.cpp:28:32: error: 'Q' was not declared in this scope
   28 |         int q = tryCombination(Q);
      |                                ^
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:36:32: error: 'S' was not declared in this scope
   36 |     for(int i = 0; i < N; i++) S[i] = D[i] = -1;
      |                                ^
cave.cpp:36:39: error: 'D' was not declared in this scope
   36 |     for(int i = 0; i < N; i++) S[i] = D[i] = -1;
      |                                       ^
cave.cpp:42:16: error: 'S' was not declared in this scope
   42 |             if(S[i] == -1) Q[i] = 0;
      |                ^
cave.cpp:42:28: error: 'Q' was not declared in this scope
   42 |             if(S[i] == -1) Q[i] = 0;
      |                            ^
cave.cpp:43:18: error: 'Q' was not declared in this scope
   43 |             else Q[i] = S[i];
      |                  ^
cave.cpp:45:32: error: 'Q' was not declared in this scope
   45 |         int q = tryCombination(Q);
      |                                ^
cave.cpp:56:12: error: 'S' was not declared in this scope
   56 |     answer(S, D);
      |            ^
cave.cpp:56:15: error: 'D' was not declared in this scope
   56 |     answer(S, D);
      |               ^