| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1355463 | nanaseyuzuki | Carnival (CEOI14_carnival) | C++20 | 2 ms | 344 KiB |
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pii pair<int, int>
#define all(a) a.begin(), a.end()
using namespace std;
#ifdef LOCAL
#include "C:\Users\Dell\Downloads\template\template\icpc-notebook\Utilities\debug.h"
#else
#define debug(...) 42
#endif
const int mn = 5e5 + 5, mod = 1e9 + 7, inf = 2e9;
int n, cnt = 0, res[mn];
int bit[mn];
void add(int u, int val) {
while(u <= n) {
bit[u] += val;
u += (u & -u);
}
}
int get(int u) {
int r = 0;
while(u) {
r += bit[u];
u -= (u & -u);
}
return r;
}
int get(int l, int r) {
return get(r) - get(l - 1);
}
int ask(vector <int> candidate) {
cout << (int) candidate.size() << ' ';
for(auto u : candidate) cout << u << ' ';
cout << endl;
int ans; cin >> ans;
return ans;
}
void solve() {
cin >> n;
for(int i = 1; i <= n; i++) {
int l = 1, r = i - 1, ans = 1;
while(l <= r) {
int mid = (l + r) >> 1;
vector <int> candidate;
for(int j = mid; j <= i; j++) candidate.push_back(j);
int val = ask(candidate);
if(val == get(mid, i - 1) + 1) {
ans = mid;
r = mid - 1;
}
else l = mid + 1;
}
if(ans == 1) {
res[i] = ++ cnt;
add(i, 1);
}
else {
add(ans - 1, -1);
res[i] = res[ans - 1];
add(i, 1);
}
}
cout << 0 << ' ';
for(int i = 1; i <= n; i++) cout << res[i] << ' ';
return;
}
signed main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr); cout.tie(nullptr);
#define task "Kawabata"
if (fopen(task".INP", "r")) {
freopen(task".INP", "r", stdin);
freopen(task".OUT", "w", stdout);
}
int t = 1;
// cin >> t;
while (t--) solve();
return 0;
}
// Don't wanna lose anymore T_T
// Never let me go - Kazuo IshiguroCompilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
