Submission #469255

#TimeUsernameProblemLanguageResultExecution timeMemory
469255Valaki2Carnival (CEOI14_carnival)C++14
100 / 100
30 ms200 KiB
#include <bits/stdc++.h> using namespace std; int query1(int l, int r, int cur) { cout << r - l + 2 << " "; for(int i = l; i <= r; ++i) cout << i << " "; cout << cur << endl; int res; cin >> res; return res; } int query2(int l, int r) { cout << r - l + 1 << " "; for(int i = l; i <= r; ++i) cout << i << " "; cout << endl; int res; cin >> res; return res; } void solve() { int n; cin >> n; vector<int> ans(1 + n, 0); vector<int> prefDiffNum(1 + n, 0); for(int i = 1; i <= n; ++i) { prefDiffNum[i] = query2(1, i); } int curCnt = 0; for(int i = 1; i <= n; ++i) { if(prefDiffNum[i] != prefDiffNum[i - 1]) { ++curCnt; ans[i] = curCnt; } else { int l = 1, r = i; while(l < r - 1) { int mid = (l + r) / 2; int a = query1(mid, r - 1, i); int b = query2(mid, r - 1); if(a == b) { l = mid; } else { r = mid; } } ans[i] = ans[l]; } } cout << "0 "; for(int i = 1; i <= n; ++i) cout << ans[i] << " "; cout << endl; } int main() { solve(); 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...