QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#740374 | #9432. Permutation | zhanghuanrui | WA | 298ms | 4096kb | C++14 | 1.4kb | 2024-11-13 09:26:15 | 2024-11-13 09:26:16 |
Judging History
answer
#include <bits/stdc++.h>
#ifdef zhr_debug
#define debug printf
#else
void debug(const char* s,...){}
#endif
using namespace std;
void freopen(string file){freopen((file+".in").c_str(),"r",stdin);freopen((file+".out").c_str(),"w",stdout);}
int n;
int ans[1020];
int ask[1020];
int query()
{
printf("0 ");
for(int i=1;i<=n;i++) printf("%d ",ask[i]);
printf("\n");fflush(stdout);
int ret;
cin>>ret;
return ret;
}
void solve(int l,int r,vector<int> &vec)
{
if(l==r)
{
ans[l]=vec[0];
return;
}
vector<int> L,R,tmp;
int mid=(l+r)>>1;
random_shuffle(vec.begin(),vec.end());
for(int x:vec)
{
if(L.size()==mid-l+1){R.push_back(x);continue;}
if(R.size()==r-mid){L.push_back(x);continue;}
if(tmp.empty()){tmp.push_back(x);continue;}
fill(ask+1,ask+n+1,tmp[0]);
fill(ask+1,ask+mid+1,x);
int res=query();
if(res==0)
{
R.push_back(x);
for(int v:tmp) L.push_back(v);
L.clear();
}
if(res==1) tmp.push_back(x);
if(res==2)
{
L.push_back(x);
for(int v:tmp) R.push_back(v);
R.clear();
}
}
if(L.size()<mid-l+1) for(int v:tmp) L.push_back(v);
if(R.size()<r-mid) for(int v:tmp) R.push_back(v);
solve(l,mid,L);
solve(mid+1,r,R);
}
int main()
{
srand(time(0));
cin>>n;
vector<int> vec;
for(int i=1;i<=n;i++) vec.push_back(i);
solve(1,n,vec);
printf("1 ");
for(int i=1;i<=n;i++) printf("%d ",ans[i]);
printf("\n");fflush(stdout);
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 4096kb
input:
5 1 0 1 0 1 0 2 0
output:
0 3 3 3 2 2 0 5 5 5 2 2 0 4 4 4 2 2 0 1 1 1 2 2 0 3 3 4 4 4 0 2 2 4 4 4 0 3 4 4 4 4 0 5 5 5 5 1 1 3 4 2 1 5
result:
ok Accepted
Test #2:
score: -100
Wrong Answer
time: 298ms
memory: 3864kb
input:
1000 1 1 1 0 1 1 0 1 1 0 1 1 0 1 0 1 1 1 1 0 1 0 0 1 0 0 0 0 0 1 0 0 0 0 0 0 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 0 1 1 0 0 0 1 1 1 0 1 0 1 1 0 0 1 1 1 1 1 1 1 1 0 0 0 1 1 0 0 1 0 0 0 0 0 0 0 0 1 0 0 1 0 0 1 0 1 1 0 1 0 0 1 1 0 1 1 1 0 0 1 1 0 0 0 1 1 0 0 0 0 1 0 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 0 0 0...
output:
0 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 121 12...
result:
wrong answer More than 6666 quries