Submission #64721

#TimeUsernameProblemLanguageResultExecution timeMemory
64721bazsi700Carnival (CEOI14_carnival)C++14
100 / 100
39 ms700 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(x); int a2 = query(v); v.pop_back(); return (a1 == a2); } void solve(vector<int> &v, int x, int currcol) { if(v.empty()) { return; } 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; } col[i] = newcol; if(i == n) { break; } vector<int> v (n-i); for(int j = i+1; j <= n; j++) { v[j-i-1] = j; } 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 'void solve(std::vector<int>&, int, int)':
carnival.cpp:46:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size()/2; i++) {
                    ~~^~~~~~~~~~~~
carnival.cpp:49:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i = 0; i < v.size()-v.size()/2; i++) {
                    ~~^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...