Submission #923520

# Submission time Handle Problem Language Result Execution time Memory
923520 2024-02-07T11:17:58 Z rolandpetrean Carnival (CEOI14_carnival) C++17
100 / 100
13 ms 944 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
// #define int ll

//#define endl '\n'
#define pb push_back
using pi = pair<int, int>;

int ask(vector<int> a) {
  cout << a.size() << " ";
  for (int i : a) cout << i << " ";
  cout << endl;
  int ans;
  cin >> ans;
  return ans;
}
int ask(int st, int dr) {
  vector<int> a;
  for (int i = st; i <= dr; ++i) a.pb(i);
  return ask(a);
}

int32_t main() {
  //ios_base::sync_with_stdio(false);
  //cin.tie(NULL);
  
  int n;
  cin >> n;
  
  int C = 0;
  vector<int> a(n + 1), pref(n + 1);
  for (int i = 1; i <= n; ++i) pref[i] = ask(1, i);
  for (int i = 1; i <= n; ++i) {
    if (pref[i] > pref[i - 1]) {
      a[i] = ++C;
      continue;
    }
    
    int st = 1, dr = i - 1, res = dr;
    while (st <= dr) {
      int mid = (st + dr) / 2;
      if (ask(mid, i) == ask(mid, i - 1)) {
        res = mid;
        st = mid + 1;
      } else dr = mid - 1;
    }
    
    a[i] = a[res];
  }
  
  cout << "0 ";
  for (int i = 1; i <= n; ++i) cout << a[i] << " ";
  cout << endl;
}

# Verdict Execution time Memory Grader output
1 Correct 9 ms 436 KB Output is correct
2 Correct 13 ms 436 KB Output is correct
3 Correct 5 ms 432 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 11 ms 688 KB Output is correct
6 Correct 9 ms 944 KB Output is correct
7 Correct 9 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 440 KB Output is correct
2 Correct 10 ms 436 KB Output is correct
3 Correct 3 ms 432 KB Output is correct
4 Correct 3 ms 440 KB Output is correct
5 Correct 9 ms 688 KB Output is correct
6 Correct 9 ms 692 KB Output is correct
7 Correct 9 ms 436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 440 KB Output is correct
2 Correct 9 ms 688 KB Output is correct
3 Correct 8 ms 432 KB Output is correct
4 Correct 2 ms 436 KB Output is correct
5 Correct 7 ms 688 KB Output is correct
6 Correct 8 ms 692 KB Output is correct
7 Correct 8 ms 688 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 944 KB Output is correct
2 Correct 10 ms 692 KB Output is correct
3 Correct 4 ms 944 KB Output is correct
4 Correct 2 ms 692 KB Output is correct
5 Correct 7 ms 436 KB Output is correct
6 Correct 5 ms 692 KB Output is correct
7 Correct 8 ms 696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 600 KB Output is correct
2 Correct 11 ms 688 KB Output is correct
3 Correct 6 ms 444 KB Output is correct
4 Correct 6 ms 692 KB Output is correct
5 Correct 6 ms 692 KB Output is correct
6 Correct 3 ms 432 KB Output is correct
7 Correct 3 ms 436 KB Output is correct