# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
815876 | Pikachu | Carnival (CEOI14_carnival) | C++17 | 26 ms | 356 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;
template<typename T>
inline bool maxi(T &x, const T &val)
{
if (x < val) return x = val, true;
return false;
}
template<typename T>
inline bool mini(T &x, const T &val)
{
if (x > val) return x = val, true;
return false;
}
const int maxn = 155;
int n;
int ans[maxn];
bool last[maxn];
set<int> rem;
int getint()
{
int tmp;
cin >> tmp;
return tmp;
}
int askrange(int l, int r)
{
cout << r - l + 1 << ' ';
for (int i = l; i <= r; i++) {
cout << i << ' ';
}
cout << endl;
return getint();
}
int askpair(int u, int v)
{
cout << 2 << ' ' << u << ' ' << v << endl;
return getint();
}
void erase(vector<int> &tmp)
{
for (int x : tmp) {
rem.erase(x);
}
tmp.clear();
}
void solve()
{
cin >> n;
int cur = askrange(1, n);
last[n] = true;
for (int i = 1; i < n; i++) {
if (askrange(i + 1, n) != cur) {
last[i] = true;
cur--;
}
else rem.insert(i);
}
int cnt = 0;
vector<int> tmp;
for (int i = 1; i <= n; i++) {
if (last[i]) {
ans[i] = ++cnt;
for (int x : rem) {
if (x > i) break;
if (askpair(x, i) == 1) {
ans[x] = cnt;
tmp.push_back(x);
}
}
erase(tmp);
}
}
cout << "0 ";
for (int i = 1; i <= n; i++) cout << ans[i] << ' ';
cout << endl;
}
signed main()
{
#ifdef LOCAL
clock_t st = clock();
#endif
ios_base::sync_with_stdio(false);
cin.tie(0);
#define Task ""
#ifdef LOCAL
if (!fopen("D:\\.inp", "r")) {
freopen("D:\\.inp", "w", stdout);
freopen("D:\\.out", "w", stdout);
cerr << "get input from file\n";
return 0;
}
freopen("D:\\.inp", "r", stdin);
freopen("D:\\.out", "w", stdout);
#else
if (fopen(Task".inp", "r")) {
freopen(Task".inp", "r", stdin);
freopen(Task".out", "w", stdout);
}
#endif
solve();
#ifdef LOCAL
cerr << clock() - st << endl;
#endif
}
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... |