Submission #1204568

#TimeUsernameProblemLanguageResultExecution timeMemory
1204568jer033Cave (IOI13_cave)C++20
Compilation error
0 ms0 KiB
//2013 IOI P4 #include "cave.h" #include <bits/stdc++.h> using namespace std; int query(int N, int[] (&S)) { int x = tryCombination(S); if (x==-1) return N; return x; } int flip_switches(int[] (&s), int[] (&assignment), int l, int r, int N) { vector<int> changes; for (int i=l; i<=r; i++) { if (assignment[i] == -1) { changes.push_back(i); s[i] = 1; } } int ans = query(N, s); for (int i: changes) s[i] = 0; return ans; } void exploreCave(int N) { int[N] switches; int[N] assignment; for (int i=0; i<N; i++) { switches[i] = 0; assignment[i] = -1; } for (int door = 0; door<N; door++) { int lo = 0; int hi = N-1; int curr = query(N, switches); while (lo!=hi) { int mid = (lo+hi)/2; if (flip_switches(switches, assignment, lo, mid, N) == curr) lo = mid+1; else hi = mid; } if (curr > door) switches[lo] = 0; else switches[lo] = 1; assignment[lo] = door; } answer(switches, assignment); }

Compilation message (stderr)

cave.cpp:6:24: error: expected ',' or '...' before '(' token
    6 | int query(int N, int[] (&S))
      |                        ^
cave.cpp: In function 'int query(int, int*)':
cave.cpp:8:28: error: 'S' was not declared in this scope
    8 |     int x = tryCombination(S);
      |                            ^
cave.cpp: At global scope:
cave.cpp:14:25: error: expected ',' or '...' before '(' token
   14 | int flip_switches(int[] (&s), int[] (&assignment), int l, int r, int N)
      |                         ^
cave.cpp: In function 'int flip_switches(int*)':
cave.cpp:17:16: error: 'l' was not declared in this scope
   17 |     for (int i=l; i<=r; i++)
      |                ^
cave.cpp:17:22: error: 'r' was not declared in this scope
   17 |     for (int i=l; i<=r; i++)
      |                      ^
cave.cpp:19:13: error: 'assignment' was not declared in this scope; did you mean 'sigevent'?
   19 |         if (assignment[i] == -1)
      |             ^~~~~~~~~~
      |             sigevent
cave.cpp:22:13: error: 's' was not declared in this scope
   22 |             s[i] = 1;
      |             ^
cave.cpp:25:21: error: 'N' was not declared in this scope
   25 |     int ans = query(N, s);
      |                     ^
cave.cpp:25:24: error: 's' was not declared in this scope
   25 |     int ans = query(N, s);
      |                        ^
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:33:8: error: structured binding declaration cannot have type 'int'
   33 |     int[N] switches;
      |        ^~~
cave.cpp:33:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
cave.cpp:33:9: error: declaration of 'auto N' shadows a parameter
   33 |     int[N] switches;
      |         ^
cave.cpp:31:22: note: 'int N' previously declared here
   31 | void exploreCave(int N)
      |                  ~~~~^
cave.cpp:33:12: error: expected initializer before 'switches'
   33 |     int[N] switches;
      |            ^~~~~~~~
cave.cpp:33:12: error: expected ';' before 'switches'
cave.cpp:34:8: error: structured binding declaration cannot have type 'int'
   34 |     int[N] assignment;
      |        ^~~
cave.cpp:34:8: note: type must be cv-qualified 'auto' or reference to cv-qualified 'auto'
cave.cpp:34:12: error: expected initializer before 'assignment'
   34 |     int[N] assignment;
      |            ^~~~~~~~~~
cave.cpp:37:9: error: 'switches' was not declared in this scope
   37 |         switches[i] = 0;
      |         ^~~~~~~~
cave.cpp:38:9: error: 'assignment' was not declared in this scope; did you mean 'sigevent'?
   38 |         assignment[i] = -1;
      |         ^~~~~~~~~~
      |         sigevent
cave.cpp:44:29: error: 'switches' was not declared in this scope
   44 |         int curr = query(N, switches);
      |                             ^~~~~~~~
cave.cpp:48:41: error: 'assignment' was not declared in this scope; did you mean 'sigevent'?
   48 |             if (flip_switches(switches, assignment, lo, mid, N) == curr)
      |                                         ^~~~~~~~~~
      |                                         sigevent
cave.cpp:57:9: error: 'assignment' was not declared in this scope; did you mean 'sigevent'?
   57 |         assignment[lo] = door;
      |         ^~~~~~~~~~
      |         sigevent
cave.cpp:59:12: error: 'switches' was not declared in this scope
   59 |     answer(switches, assignment);
      |            ^~~~~~~~
cave.cpp:59:22: error: 'assignment' was not declared in this scope; did you mean 'sigevent'?
   59 |     answer(switches, assignment);
      |                      ^~~~~~~~~~
      |                      sigevent