QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#741078#9432. PermutationL_WaveWA 1ms3804kbC++201.8kb2024-11-13 13:16:302024-11-13 13:16:31

Judging History

你现在查看的是最新测评结果

  • [2024-11-13 13:16:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3804kb
  • [2024-11-13 13:16:30]
  • 提交

answer

// Problem: K. Permutation
// Author: XZC(L_Wave)
// Language: Cpp/G++20
// Contest: Hydro
// URL: http://www.nfls.com.cn:10611/p/16530?tid=67333207920ee48161ddde7f
// Memory Limit: 1024 MB
// Time Limit: 1000 ms
// Create Time: not 2024-11-13 11:43:37, but 1926-08-17 11:45:14
// 
// Powered by CP Editor (https://cpeditor.org)

#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = (a), i##ABRACADABRA = (b); i <= i##ABRACADABRA; i++)
#define drep(i, a, b) for (int i = (a), i##ABRACADABRA = (b); i >= i##ABRACADABRA; i--)
using namespace std;
using ll = long long;

int n,res[1000010];

int ask(int x,int y,int piv){
  putchar(48);
  rep(i,1,piv)printf(" %d",x);
  rep(i,piv+1,n)printf(" %d",y);
  puts(""),fflush(stdout);
  scanf("%d",&piv);
  return piv;
}

void solve(int l,int r,vector<int>V){
  if (l==r)return void(res[l]=!V.size()?0:V[0]);
  vector<int>L,R,U;
  int mid=(l+r)>>1;
  for (auto v:V){
    if ((int)L.size()==mid-l+1){
      R.push_back(v);
      continue;
    }else if ((int)R.size()==r-mid){
      L.push_back(v);
      continue;
    }else{
      if (!U.size()){
        U.push_back(v);
        continue;
      }
      int x=ask(v,U[0],mid);
      if (x==1){
        U.push_back(x);
        continue;
      }
      if (!x){
        for (auto t:U)L.push_back(t);
        U.clear();
        R.push_back(v);
      }else{
        for (auto t:U)R.push_back(t);
        U.clear();
        L.push_back(v);
      }
    }
  }
  if ((int)L.size()+(int)U.size()==mid-l+1)
    for (auto t:U)L.push_back(t);
  else
    for (auto t:U)R.push_back(t);
  solve(l,mid,L),solve(mid+1,r,R);
}

int main() {
  scanf("%d",&n);
  vector<int>V;
  rep(i,1,n)V.push_back(i);
  solve(1,n,V);
  putchar(49);
  rep(i,1,n)printf(" %d",res[i]);
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3804kb

input:

5
2
1
0
2
0
0

output:

0 2 2 2 1 1
0 4 4 4 3 3
0 5 5 5 3 3
0 3 3 2 2 2
0 1 3 3 3 3
0 5 5 5 5 1
1 3 1 2 1 5

result:

wrong answer Wrong Anser