Submission #532273

# Submission time Handle Problem Language Result Execution time Memory
532273 2022-03-02T16:13:32 Z devariaota Carnival (CEOI14_carnival) C++17
0 / 100
9 ms 200 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 << " ";
    for(int i=l;i<=r;i++)
    {
      cout << q[i] << " ";
    }
    cout << x << 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;
      while(l <= r){
        // cout << "-> " << l << " " << r << endl;
        int mid = (l + r) / 2;
        int z = ask2(l, mid, i);
        if(z == mid - l + 2)
        {
          l = mid + 1;
        }
        else
        {
          r = mid - 1;
        }
      }
      a[i] = q[l];
    }
  }  
  cout << "0 ";
  for(int i=1;i<=n;i++)
  {
    cout << a[i] << " ";
  }
  cout << endl;
  
}
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 200 KB Integer 19 violates the range [1, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 200 KB Integer 6 violates the range [1, 5]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 200 KB Output is correct
2 Incorrect 7 ms 200 KB Integer 11 violates the range [1, 8]
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 200 KB Integer 5 violates the range [1, 4]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 200 KB Output is correct
2 Incorrect 9 ms 200 KB Integer 22 violates the range [1, 17]
3 Halted 0 ms 0 KB -