Submission #151951

#TimeUsernameProblemLanguageResultExecution timeMemory
151951forestryksCarnival (CEOI14_carnival)C++14
100 / 100
21 ms504 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; using ld = long double; using pii = pair<int, int>; #define rep(i, n) for (int (i) = 0; (i) < (n); ++(i)) #define all(x) (x).begin(), (x).end() #define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); #define f first #define s second const int MAXN = 155; int n; int a[MAXN]; int cnt[MAXN][MAXN]; int ask(int l, int r) { cout << r - l + 1; for (int i = l; i <= r; ++i) { cout << ' ' << i + 1; } cout << endl; int x; cin >> x; return x; } int main() { FAST_IO; cin >> n; cnt[n - 1][n - 1] = 1; fill(a, a + n, -1); int last = 1; a[n - 1] = 0; for (int i = n - 2; i >= 0; --i) { int l = i, r = n; while (r - l > 1) { int m = l + (r - l) / 2; if (ask(i, m) == cnt[i + 1][m] + 1) { l = m; } else { r = m; } } if (r == n) a[i] = last++; else a[i] = a[r]; // for (int j = i + 1; j < n; ++j) { // int x = ask(i, j); // if (x != cnt[i + 1][j] + 1) { // a[i] = a[j]; // break; // } // } // if (a[i] == -1) a[i] = last++; set<int> s; for (int j = i; j < n; ++j) { s.insert(a[j]); cnt[i][j] = s.size(); } } cout << 0; rep(i, n) { cout << ' ' << a[i] + 1; } cout << endl; }
#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...