QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#744893 | #9432. Permutation | chrhaa | RE | 1ms | 3860kb | C++14 | 1.1kb | 2024-11-14 00:16:19 | 2024-11-14 00:16:20 |
Judging History
answer
#define _CRT_SECURE_NO_WARNINGS 1
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
const int N=1005;
int n,a[N];
inline int calc(int p,int x,int y){
putchar(48);
for(int i=1;i<=p;i++) printf(" %d",x);
for(int i=p+1;i<=n;i++) printf(" %d",y);
putchar('\n');
fflush(stdout);
scanf("%d",&x);
return x;
}
void solve(int l,int r,vector<int> &b){
if(l==r){
a[l]=b[0];
return ;
}
random_shuffle(b.begin(),b.end());
vector<int> c[2];
int p,i,o,mid=l+r>>1;
for(i=p=0;i+1<b.size();i++){
o=calc(mid,b[i],b[i+1]);
if(o!=1){
for(o=!o;p<=i;p++)
c[o].push_back(b[p]);
c[o^1].push_back(b[p]);
p++;
i++;
}
}
if(p!=b.size()){
o=(c[o].size()==mid-l+1);
for(;p<b.size();p++)
c[o].push_back(b[p]);
}
solve(l,mid,c[0]);
solve(mid+1,r,c[1]);
}
signed main(){
int i;
vector<int> b;
scanf("%d",&n);
for(i=1;i<=n;i++) b.push_back(i);
solve(1,n,b);
putchar(49);
for(i=1;i<=n;i++) printf(" %d",a[i]);
putchar('\n');
fflush(stdout);
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3860kb
input:
5 0 1 2 1 2 2 2
output:
0 5 5 5 4 4 0 2 2 2 3 3 0 3 3 3 1 1 0 4 4 3 3 3 0 3 3 2 2 2 0 3 4 4 4 4 0 1 1 1 1 5 1 3 4 2 1 5
result:
ok Accepted
Test #2:
score: -100
Runtime Error
input:
1000 1 2 1 1 0 0 2 2 0 1 2 0 1 1 1 2 2 0 0 1 1 1 1 0 1 1 0 1 0 1 0 1 0 2 2 2 1 0 1 0 1 0 1 0 1 2 2 1 1 1 1 1 1 0 0 1 1 1 1 1 2 2 2 2 2 1 2 2 1 1 0 1 0 1 2 1 1 2 1 0 0 1 0 2 2 2 1 0 0 1 0 1 0 0 0 2 2 1 1 1 1 1 1 0 0 1 0 2 1 2 1 1 1 0 1 1 1 0 1 0 2 0 1 2 1 1 1 1 1 1 2 1 0 2 1 1 0 2 2 1 2 1 2 1 1 1 1 0...
output:
0 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 111 11...