Submission #540395

#TimeUsernameProblemLanguageResultExecution timeMemory
540395alextodoranCarnival (CEOI14_carnival)C++17
100 / 100
29 ms336 KiB
/** ____ ____ ____ ____ ____ ||a |||t |||o |||d |||o || ||__|||__|||__|||__|||__|| |/__\|/__\|/__\|/__\|/__\| **/ #include <bits/stdc++.h> using namespace std; typedef long long ll; const int N_MAX = 150; int ask (vector <int> v) { if ((int) v.size() <= 1) { return (int) v.size(); } cout << (int) v.size() << " "; for (int i : v) { cout << i << " "; } cout << endl; int resp; cin >> resp; return resp; } int N; int C[N_MAX + 2]; bool isNew (int l, int r) { vector <int> v; for (int i = l; i < r; i++) { v.push_back(i); } int without = ask(v); v.push_back(r); int with = ask(v); return (without < with); } int main () { cin >> N; int k = 0; for (int i = 1; i <= N; i++) { // find the first equal to the left int l = 0, r = i - 1; while (l < r) { int mid = (l + r + 1) / 2; if (isNew(mid, i) == true) { r = mid - 1; } else { l = mid; } } C[i] = (l > 0 ? C[l] : ++k); } cout << 0 << " "; for (int i = 1; i <= N; i++) { cout << C[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...