Submission #204706

#TimeUsernameProblemLanguageResultExecution timeMemory
204706bogdan_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; // void answer(int a[], int b[]) { // for (int i = 0; i < N; i++) cout << a[i] << ' '; cout << '\n'; // for (int i = 0; i < N; i++) cout << b[i] << ' '; cout << '\n'; // } // int tryCombination(...) { // return 1; // } vector <int> sett(vector <int> s, vector <int> fnd, int pos, int f) { vector <int> temp = s; for (int i = 0; i < pos; i++) { if (!fnd[i]) { temp[i] = f; } } for (int i = pos; i < s.size(); i++) { if (!fnd[i]) { temp[i] = !f; } } int ans[temp.size()]; for (int i = 0; i < temp.size(); i++) ans[i] = temp[i]; return ans; } void exploreCave(int n) { vector <int> s(n, 0); vector <int> p(n, 0); vector <int> fnd(n, 0); for (int i = 0; i < n; i++) { // find the switch connected with i-th door // find the switch position 1/0 int k = tryCombination(sett(s, fnd, n, 1)); // 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; int k = tryCombination(sett(s, fnd, m + 1, f)); if (k >= i + 1) { r = m; } else { l = m + 1; } } k = tryCombination(sett(s, fnd, l + 1, f)); if (k >= i + 1) { p[l] = i; s[l] = f; fnd[l] = true; } else { p[r] = i; s[r] = f; fnd[r] = true; } } int S[n], P[n]; for (int i = 0; i < n; i++) { S[i] = s[i]; P[i] = p[i]; } answer(S, P); } // signed main() { // N = 10; // exploreCave(N); // return 0; // }

Compilation message (stderr)

cave.cpp: In function 'std::vector<int> sett(std::vector<int>, std::vector<int>, int, int)':
cave.cpp:20:25: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = pos; i < s.size(); i++) {
                       ~~^~~~~~~~~~
cave.cpp:26:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (int i = 0; i < temp.size(); i++) ans[i] = temp[i];
                     ~~^~~~~~~~~~~~~
cave.cpp:27:12: error: could not convert 'ans' from 'int [(<anonymous> + 1)]' to 'std::vector<int>'
     return ans;
            ^~~
cave.cpp: In function 'void exploreCave(int)':
cave.cpp:36:50: error: cannot convert 'std::vector<int>' to 'int*' for argument '1' to 'int tryCombination(int*)'
         int k = tryCombination(sett(s, fnd, n, 1));
                                                  ^
cave.cpp:49:58: error: cannot convert 'std::vector<int>' to 'int*' for argument '1' to 'int tryCombination(int*)'
             int k = tryCombination(sett(s, fnd, m + 1, f));
                                                          ^
cave.cpp:57:50: error: cannot convert 'std::vector<int>' to 'int*' for argument '1' to 'int tryCombination(int*)'
         k = tryCombination(sett(s, fnd, l + 1, f));
                                                  ^