Submission #204715

#TimeUsernameProblemLanguageResultExecution timeMemory
204715bogdan_ogorodniyCave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; const int inf = 1e9 + 7; int N; int _S[5001], _P[5001]; // void answer(int a[], int b[]) { // for (int i = 0; i < N; i++) cout << a[i] << ' '; cout << '\t'; for (int i = 0; i < N; i++) cout << _S[i] << ' '; cout << '\n'; // for (int i = 0; i < N; i++) cout << b[i] << ' '; cout << '\t'; for (int i = 0; i < N; i++) cout << _P[i] << ' '; cout << '\n'; // } // int tryCombination(int a[]) { // int ans = 0; // vector <int> op(N + 1, 0); // for (int i = 0; i < N; i++) { // if (_S[i] == a[i]) op[_P[i]] = true; // } // while (op[ans++]); // return ans; // } int temp[5001]; void sett(int pos, int f) { memset(temp, 0, sizeof temp); for (int i = 0; i < pos; i++) { if (!fnd[i]) { temp[i] = f; } else { temp[i] = s[i]; } } for (int i = pos; i < s.size(); i++) { if (!fnd[i]) { temp[i] = !f; } else { temp[i] = s[i]; } } } int s[5001], p[5001]; bool fnd[5001]; void exploreCave(int n) { for (int i = 0; i < n; i++) { // find the switch connected with i-th door // find the switch position 1/0 sett(s, fnd, n, 1); int k = tryCombination(temp); // in (fnd) -- already used swithces bool f = 0; if (k >= i + 1) { f = true; } else { f = false; } int l = 0, r = n - 1; while (r - l > 1) { int m = (l + r) / 2; sett(s, fnd, m + 1, f); int k = tryCombination(temp); if (k >= i + 1) { r = m; } else { l = m; } } sett(s, fnd, l + 1, f); k = tryCombination(temp); if (k >= i + 1) { p[l] = i; s[l] = f; fnd[l] = true; } else { p[r] = i; s[r] = f; fnd[r] = true; } } answer(s, p); } // signed main() { // N = 10; // for (int i = 0; i < N; i++) { // _P[i] = i; // } // random_shuffle(_P, _P + N); // for (int i = 0; i < N; i++) { // srand(time(nullptr)); // _S[i] = rand() % 2; // } // exploreCave(N); // return 0; // }

Compilation message (stderr)

cave.cpp: In function 'void sett(int, int)':
cave.cpp:24:14: error: 'fnd' was not declared in this scope
         if (!fnd[i]) {
              ^~~
cave.cpp:28:23: error: 's' was not declared in this scope
             temp[i] = s[i];
                       ^
cave.cpp:31:27: error: 's' was not declared in this scope
     for (int i = pos; i < s.size(); i++) {
                           ^
cave.cpp:32:14: error: 'fnd' was not declared in this scope
         if (!fnd[i]) {
              ^~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:46:26: error: invalid conversion from 'int*' to 'int' [-fpermissive]
         sett(s, fnd, n, 1);
                          ^
cave.cpp:46:26: error: invalid conversion from 'bool*' to 'int' [-fpermissive]
cave.cpp:46:26: error: too many arguments to function 'void sett(int, int)'
cave.cpp:21:6: note: declared here
 void sett(int pos, int f) {
      ^~~~
cave.cpp:60:34: error: invalid conversion from 'int*' to 'int' [-fpermissive]
             sett(s, fnd, m + 1, f);
                                  ^
cave.cpp:60:34: error: invalid conversion from 'bool*' to 'int' [-fpermissive]
cave.cpp:60:34: error: too many arguments to function 'void sett(int, int)'
cave.cpp:21:6: note: declared here
 void sett(int pos, int f) {
      ^~~~
cave.cpp:69:30: error: invalid conversion from 'int*' to 'int' [-fpermissive]
         sett(s, fnd, l + 1, f);
                              ^
cave.cpp:69:30: error: invalid conversion from 'bool*' to 'int' [-fpermissive]
cave.cpp:69:30: error: too many arguments to function 'void sett(int, int)'
cave.cpp:21:6: note: declared here
 void sett(int pos, int f) {
      ^~~~