# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1008497 | VMaksimoski008 | Carnival (CEOI14_carnival) | C++17 | 5 ms | 596 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
//#define int long long
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int mod = 1e9 + 7;
const int LOG = 20;
const int maxn = 1e5 + 5;
signed main() {
int n;
cin >> n;
vector<int> diff;
vector<int> v(n+1);
v[1] = 1;
diff.push_back(1);
auto query = [&](vector<int> &vec) {
cout << vec.size();
for(int &el : vec) cout << " " << el;
cout << endl;
int ans;
cin >> ans;
return ans;
};
int id = 2;
for(int i=2; i<=n; i++) {
int x = diff.size();
diff.push_back(i);
if(query(diff) == diff.size()) {
v[i] = id++;
continue;
}
diff.pop_back();
int l=0, r=diff.size()-1, p=r;
while(l <= r) {
int mid = (l + r) / 2;
vector<int> vec;
for(int j=0; j<=mid; j++) vec.push_back(diff[j]);
vec.push_back(i);
if(query(vec) == vec.size() - 1) p = mid, r = mid - 1;
else l = mid + 1;
}
v[i] = v[diff[p]];
}
cout << 0;
for(int i=1; i<=n; i++) cout << " " << v[i];
cout << endl;
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |