Submission #532259

# Submission time Handle Problem Language Result Execution time Memory
532259 2022-03-02T15:25:59 Z makanhulia Carnival (CEOI14_carnival) C++17
0 / 100
2 ms 456 KB
#include <bits/stdc++.h>
using namespace std;

int main(){
  cin.tie(0) -> ios_base::sync_with_stdio(0);

  int n;
  cin >> n;
  vector<int> a(n + 1), q(n + 1);
  auto ask = [&](int l, int r) -> int {
    cout << r - l + 1 << " ";
    for(int i=l;i<=r;i++)
    {
      cout << i << " ";
    }
    cout << endl;
    int ret;
    cin >> ret;
    return ret;
  };
  auto ask2 = [&](int l, int r, int x) -> int{
    cout << r - l + 2 << " " << x << " ";
    for(int i=l;i<=r;i++)
    {
      cout << q[i] << " ";
    }
    cout << endl;
    int ret;
    cin >> ret;
    return ret;
  };
  for(int i=1,cur=0;i<=n;i++)
  {
    // cout << ":: " << i << " " << cur << endl;
    // cout << "! ";
    // for(int i=1;i<=cur;i++)
    // {
    //   cout << q[i] << " ";
    // }
    // cout << endl;
    int t = ask(1, i);
    if(t > cur)
    {
      cur++;
      q[cur] = i;
      a[i] = cur;
    }
    else
    {
      int l = 1, r = cur, ans = -1;
      while(l < r){
        int mid = (l + r) / 2;
        if(ask2(l, mid, i) < mid - l + 2)
        {
          r = mid - 1, ans = mid;
        }
        else
        {
          l = mid + 1;
        }
      }
      // cout << "binser : " << ans << endl;
      assert(ans != -1);
      a[i] = q[ans];
    }
  }  
  cout << "0 ";
  for(int i=1;i<=n;i++)
  {
    cout << a[i] << " ";
//     assert(a[i] > 0);
  }
  cout << endl;
  
}
# Verdict Execution time Memory Grader output
1 Runtime error 2 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 432 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 456 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -