Submission #64719

#TimeUsernameProblemLanguageResultExecution timeMemory
64719bazsi700Carnival (CEOI14_carnival)C++14
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; #define ll long long int col[151]; int query(vector<int> &v) { cout << v.size() << " " for(int el : v) { cout << el << " "; } cout << "\n" << flush; int x; cin >> x; return x; } bool hasmatch(vector<int> &v, int x) { if(v.size() == 1) { v.push_back(x); int a1 = query(v); v.pop_back(); return (a1 == 1); } int a1 = query(v); v.push_back(i); int a2 = query(x); v.pop_back(); return (a1 == a2); } void solve(vector<int> &v, int x, int currcol) { if(!hasmatch(v,x)) { return; } if(v.size() == 1) { col[v][0] = currcol; return; } vector<int> v1 (v.size()/2); vector<int> v2 (v.size()-v.size()/2); for(int i = 0; i < v.size()/2; i++) { v1[i] = v[i]; } for(int i = 0; i < v.size()-v.size()/2; i++) { v2[i] = v[i+v.size()/2]; } solve(v1,x,currcol); solve(v2,x,currcol); } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; int newcol = 1; for(int i = 1; i <= n; i++) { if(col[i] != 0) { continue; } vector<int> v (n-i); for(int j = i+1; j <= n; j++) { v[j-i-1] = j; } col[i] = newcol; solve(v,i,newcol++); } cout << "0 "; for(int i = 1; i <= n; i++) { cout << col[i] << " "; } return 0; }

Compilation message (stderr)

carnival.cpp: In function 'int query(std::vector<int>&)':
carnival.cpp:10:5: error: expected ';' before 'for'
     for(int el : v) {
     ^~~
carnival.cpp: In function 'bool hasmatch(std::vector<int>&, int)':
carnival.cpp:27:17: error: 'i' was not declared in this scope
     v.push_back(i);
                 ^
carnival.cpp:28:21: error: invalid initialization of reference of type 'std::vector<int>&' from expression of type 'int'
     int a2 = query(x);
                     ^
carnival.cpp:8:5: note: in passing argument 1 of 'int query(std::vector<int>&)'
 int query(vector<int> &v) {
     ^~~~~
carnival.cpp: In function 'void solve(std::vector<int>&, int, int)':
carnival.cpp:38:12: error: no match for 'operator[]' (operand types are 'int [151]' and 'std::vector<int>')
         col[v][0] = currcol;
            ^
carnival.cpp:43:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size()/2; i++) {
                    ~~^~~~~~~~~~~~
carnival.cpp:46:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size()-v.size()/2; i++) {
                    ~~^~~~~~~~~~~~~~~~~~~~~