Submission #311642

#TimeUsernameProblemLanguageResultExecution timeMemory
311642saarang123Cave (IOI13_cave)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "cave.h" using namespace std; using ll = long long; using ld = long double; #define all(x) x.begin(), x.end() #define pb push_back #define mp make_pair template<class T> bool remin(T& a, const T& b) { return a > b ? a = b, 1 : 0; } template<class T> bool remax(T& a, const T& b) { return a < b ? a = b, 1 : 0; } std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count()); /* void answer(vector<int> s, vector<int> d) { cout << "Code: "; for(int c : s) cout << c << " "; cout << endl; cout << "Doors: "; for(int c : d) cout << c << " "; cout << endl; cout << "Exit" << endl; } int tryCombination(vector<int> s) { cout << "Query for doors: "; for(int c : s) cout << c << " "; cout << endl; int x; cin >> x; return x; } */ int binsearch(vector<int> a, int k) { int mn = 0, mx = a.size() - 1; while(mn < mx) { int mid = (mn + mx) >> 1; for(int i = mn; i <= mid; i++) a[i] ^= 1; int x = tryCombination(a); for(int i = mn; i <= mid; i++) a[i] ^= 1; if(x != k) mx = mid; else mn = mid + 1; } return mn; } void exploreCave(int n) { vector<int> a(n, 0), d(n, -1); int x = tryCombination(a); while(x != -1) { int id = binsearch(a, x); d[id] = x; a[id] ^= 1; x = tryCombination(a); } vector<int> s = a; for(int i = 0; i < n; i++) { if(d[i] != -1) continue; s[i] ^= 1; d[i] = tryCombination(s); s[i] ^= 1; } answer(s, d); } /* signed main() { std::ios::sync_with_stdio(0); std::cout.tie(0); std::cin.tie(0); int n, i, j; cin >> n; exploreCave(n); return 0; }*/

Compilation message (stderr)

cave.cpp: In function 'int binsearch(std::vector<int>, int)':
cave.cpp:37:32: error: cannot convert 'std::vector<int>' to 'int*'
   37 |         int x = tryCombination(a);
      |                                ^
      |                                |
      |                                std::vector<int>
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:50:28: error: cannot convert 'std::vector<int>' to 'int*'
   50 |     int x = tryCombination(a);
      |                            ^
      |                            |
      |                            std::vector<int>
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:55:28: error: cannot convert 'std::vector<int>' to 'int*'
   55 |         x = tryCombination(a);
      |                            ^
      |                            |
      |                            std::vector<int>
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:61:31: error: cannot convert 'std::vector<int>' to 'int*'
   61 |         d[i] = tryCombination(s);
      |                               ^
      |                               |
      |                               std::vector<int>
In file included from cave.cpp:2:
cave.h:8:24: note:   initializing argument 1 of 'int tryCombination(int*)'
    8 | int tryCombination(int S[]);
      |                    ~~~~^~~
cave.cpp:64:12: error: cannot convert 'std::vector<int>' to 'int*'
   64 |     answer(s, d);
      |            ^
      |            |
      |            std::vector<int>
In file included from cave.cpp:2:
cave.h:9:17: note:   initializing argument 1 of 'void answer(int*, int*)'
    9 | void answer(int S[], int D[]);
      |             ~~~~^~~