QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#741078 | #9432. Permutation | L_Wave | WA | 1ms | 3804kb | C++20 | 1.8kb | 2024-11-13 13:16:30 | 2024-11-13 13:16:31 |
Judging History
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;
}
详细
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