# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
538338 | Sorting | Carnival (CEOI14_carnival) | C++17 | 16 ms | 340 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>
using namespace std;
typedef long long ll;
template<class T> void check_min(T &a, const T &b){ a = (a < b) ? a : b; }
template<class T> void check_max(T &a, const T &b){ a = (a > b) ? a : b; }
#define all(x) (x).begin(), (x).end()
const int N = 150 + 3;
int n;
int t[N], types = 1;
vector<int> v;
int query(const vector<int> &v){
cout << v.size() << " ";
for(int x: v)
cout << x << " ";
cout << endl;
int res;
cin >> res;
return res;
}
int query(const vector<int> &v, int pos, int x){
vector<int> v2 = v;
while(v2.size() > pos)
v2.pop_back();
v2.push_back(x);
return query(v2);
}
int main(){
ios::sync_with_stdio(false);
cin.tie(NULL);
cin >> n;
t[1] = 1;
v.push_back(1);
for(int i = 2; i <= n; ++i){
int l = 0, r = (int)v.size();
while(l != r){
int mid = (l + r + 1) >> 1;
if(query(v, mid, i) == mid + 1)
l = mid;
else
r = mid - 1;
}
if(l == (int)v.size()){
v.push_back(i);
t[i] = ++types;
}
else{
t[i] = t[v[l]];
}
}
cout << "0 ";
for(int i = 1; i <= n; ++i)
cout << t[i] << " ";
cout << endl;
}
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... |