QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#744203 | #9432. Permutation | jiamengtong | RE | 0ms | 3860kb | C++14 | 1.1kb | 2024-11-13 21:09:16 | 2024-11-13 21:09:17 |
Judging History
answer
#include<bits/stdc++.h>
#define M 1005
using namespace std;
int n, ans[M], a[M];
int ask(int l, int r, int x, int y)
{
int mid = (l + r) >> 1;
printf("0 ");
for(int i = 1; i <= mid; i++) printf("%d ", x);
for(int i = mid + 1; i <= n; i++) printf("%d ", y);
puts("");
fflush(stdout);
int res;
scanf("%d", &res);
return res;
}
void solve(int l, int r, vector<int> v)
{
if(l == r)
{
ans[l] = v[0];
return;
}
random_shuffle(v.begin(), v.end());
vector<int> L[2];
int fl = 0, lst = 0;
L[0].push_back(v[0]);
for(int i = 1; i < v.size(); i++)
{
int w = ask(l, r, v[i - 1], v[i]);
if(w != 1)
{
L[lst ^ 1].push_back(v[i]), lst ^= 1;
if(!fl)
{
if(w == 0) fl = lst;
else fl = lst ^ 1;
}
}
else
{
L[lst].push_back(v[i]);
}
}
int mid = (l + r) >> 1;
solve(l, mid, L[fl]);
solve(mid + 1, r, L[fl ^ 1]);
}
int main()
{
scanf("%d", &n);
vector<int> v;
for(int i = 1; i <= n; i++) v.push_back(i);
solve(1, n, v);
printf("1 ");
for(int i = 1; i <= n; i++) printf("%d ", ans[i]);
puts("");
fflush(stdout);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3860kb
input:
5 0 1 1 2 1 2 2 2
output:
0 5 5 5 4 4 0 4 4 4 2 2 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 1 0 2 0 1 2 0 2 1 0 1 1 2 1 0 1 1 1 1 2 0 2 1 0 2 0 2 1 1 1 1 0 2 1 1 0 2 1 0 2 1 0 2 1 0 1 2 0 2 0 2 1 1 0 2 1 0 2 1 0 2 1 0 1 1 2 0 2 1 1 1 1 1 1 1 0 2 0 1 1 1 1 1 1 2 0 2 0 2 0 2 0 2 0 1 2 0 2 1 1 1 0 2 1 0 1 1 2 0 1 1 2 1 1 0 2 0 2 1 0 1 2 0 2 0 2 1 1 0 2 0 2 1 0 2 1 0 2 0 2 0 1 2 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...