Submission #620205

# Submission time Handle Problem Language Result Execution time Memory
620205 2022-08-03T03:39:44 Z czhang2718 Super Dango Maker (JOI22_dango3) C++17
0 / 100
27 ms 556 KB
#include "dango3.h"
#include <bits/stdc++.h>
using namespace std;

#define rep(i,a,b) for(int i=a; i<=b; i++)

int qry(vector<int> v){
  cout << "? ";
  for(int x:v) cout << x << " ";
  cout << endl;
int ret; cin >> ret;
return ret;
}

void ans(vector<int> v){
  cout << "! ";
  for(int x:v) cout << x << " ";
    cout << endl;
}
vector<vector<int>> dango;
bool ki[100000];
vector<int> idx;

void solve(int l, int r, int li, int ri){
  if(r<l) return;
  int m=(l+r)/2;
  int p=li-1;
  auto ck=[&](int p)->bool{
    // cout << "try " << p << endl;
    vector<int> qu;
    for(int i=0; i<=p; i++){
      qu.push_back(idx[i]);
    }
    for(int i=0; i<m; i++){
      for(int x:dango[i]) qu.push_back(x);
    }
    for(int &x:qu) x++;
    return Query(qu)<m;
  };
  for(int k=31-__builtin_clz(ri-li+1); k>=0; k--){
    if(p+(1<<k)<ri && ck(p+(1<<k))) p+=(1<<k);
  }
  p++;
  ki[p]=1;
  // cout << "ki " << p << " = " << it << endl;
  solve(l, m-1, li, p-1);
  solve(m+1, r, p, ri);
}

void Solve(int n, int m) {
  dango.resize(m);
  idx.resize(n*m);
  iota(idx.begin(), idx.end(), 0);

  for(int it=1; it<=n; it++){
    int N=idx.size();
    solve(1, m, 0, N-1);
    int j=0;
    vector<int> idx2;
    for(int i=0; i<N; i++){
      if(ki[i]){
        dango[j++].push_back(i);
      }
      else idx2.push_back(i);
      ki[i]=0;
    }
    swap(idx, idx2);
  }

  for(int i=0; i<m; i++){
    for(int &x:dango[i]) x++;
    Answer(dango[i]);
  }
}

// int main(){
//   Solve(3, 2);
// }
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 340 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 11 ms 480 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 556 KB Wrong Answer [2]
2 Halted 0 ms 0 KB -