Submission #715334

#TimeUsernameProblemLanguageResultExecution timeMemory
715334studyCarnival (CEOI14_carnival)C++17
100 / 100
9 ms316 KiB
#include <bits/stdc++.h> using namespace std; const int N = 151; int color[N]; vector<int> people; int query(vector<int>& v){ cout << v.size(); for (int i:v) cout << ' ' << i; cout << endl; int a; cin >> a; return a; } int query(int deb, int fin, int pos){ cout << fin-deb+2; for (int i=deb; i<=fin; ++i){ cout << ' ' << people[i]; } cout << ' ' << pos; cout << endl; int a; cin >> a; return a; } void dc(int deb, int fin, int pos){ if (deb == fin){ color[pos] = color[people[deb]]; return; } int mid = (deb+fin)/2; if (query(deb,mid,pos) == mid-deb+1){ dc(deb,mid,pos); } else dc(mid+1,fin,pos); } int main(){ ios::sync_with_stdio(0); cin.tie(0); int n; cin >> n; int prev = 0; for (int i=1; i<=n; ++i){ people.emplace_back(i); if (query(people) != prev+1){ people.pop_back(); } else prev++; } int ans = 1; for (int i:people){ color[i] = ans; ans++; } for (int i=1; i<=n; ++i){ if (color[i] == 0){ dc(0,people.size()-1,i); } } cout << 0; for (int i=1; i<=n; ++i){ cout << ' ' << color[i]; } cout << endl; return 0; }
#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...