QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#473155 | #7757. Palm Island | yzhang | WA | 1ms | 3744kb | C++14 | 1.2kb | 2024-07-11 22:34:00 | 2024-07-11 22:34:02 |
Judging History
answer
#include<bits/stdc++.h>
#define N 1005
using namespace std;
int T,n,a[N],b[N],ndp[N];
int pre[N],nxt[N],bg,ed;
void op1(){
pre[bg]=ed;
nxt[ed]=bg;
bg=nxt[bg];
ed=nxt[ed];
cout<<"1";
}
void op2(){
pre[nxt[nxt[bg]]]=bg;
pre[nxt[bg]]=ed;
nxt[ed]=nxt[bg];
ed=nxt[ed];
nxt[bg]=nxt[nxt[bg]];
cout<<"2";
}
void print(){
int cur=bg;
for(int i=1;i<=n;++i){
cerr<<cur<<" ";
cur=nxt[cur];
}
cerr<<'\n';
}
void solve(){
cin>>n;
for(int i=1;i<=n;++i) cin>>a[i];
for(int i=1;i<=n;++i) cin>>b[i];
pre[a[n]]=a[n-1],nxt[a[1]]=a[2];
bg=a[1],ed=a[n];
for(int i=2;i<n;++i)
pre[a[i]]=a[i-1],nxt[a[i]]=a[i+1];
ndp[b[1]]=b[n];
for(int i=2;i<=n;++i)
ndp[b[i]]=b[i-1];
int cnt=0;
for(int i=1;i<=n*(n-1);++i){
if(ndp[bg]==ed) op1();
else if(ndp[nxt[bg]]!=bg)
op2();
else
op1();
// print();
}
for(int i=1;i<=n;++i){
if(bg==b[1]){
cout<<'\n';
return;
}
op1();
}
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0);
cin>>T;
while(T--)
solve();
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3684kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
1111111 211111111111
result:
ok Correct. (2 test cases)
Test #2:
score: 0
Accepted
time: 1ms
memory: 3696kb
input:
200 3 3 1 2 2 3 1 4 2 4 1 3 2 1 4 3 4 1 4 2 3 2 1 3 4 5 4 3 2 1 5 2 4 5 3 1 5 2 1 5 4 3 5 2 4 1 3 4 4 3 1 2 1 2 4 3 3 1 2 3 3 1 2 4 1 4 2 3 2 1 4 3 4 1 3 2 4 1 4 3 2 3 3 2 1 1 3 2 3 2 3 1 1 3 2 4 1 4 3 2 3 1 2 4 3 1 2 3 1 3 2 3 3 2 1 2 3 1 5 5 1 3 2 4 2 4 5 1 3 4 4 3 1 2 1 4 3 2 4 1 3 4 2 2 4 3 1 3 ...
output:
11111111 121111111111 2211111111111 221221111111111111111 221121111111111111111 11111111111111 11111111 112111111111111 22111111111111 11111111 21111111 2211111111111 2111111 211111 11111111111111111111111 112111111111111 21211111111111 1111111 111111111111 1221111111111111111111 11211111111111 2121...
result:
ok Correct. (200 test cases)
Test #3:
score: 0
Accepted
time: 1ms
memory: 3744kb
input:
200 5 5 1 3 4 2 5 3 2 4 1 5 5 1 2 4 3 3 5 4 1 2 5 1 4 5 3 2 2 5 4 3 1 5 1 5 4 3 2 4 5 2 3 1 5 2 3 4 5 1 5 4 3 2 1 5 1 5 2 4 3 5 3 1 2 4 5 1 2 4 3 5 4 2 3 5 1 5 3 2 1 4 5 4 2 3 1 5 5 3 1 2 5 4 2 4 1 3 5 5 5 3 1 4 2 2 5 4 1 3 5 5 4 3 1 2 2 5 4 1 3 5 3 4 5 2 1 3 5 1 4 2 5 4 5 1 3 2 4 2 3 1 5 5 1 3 4 5 ...
output:
211211111111111111111 11122111111111111111111 222112111111111111111111 211212211111111111111 2121221111111111111111 12211111111111111111111 121111111111111111111 211211111111111111111111 21211111111111111111111 12122111111111111111111 112111111111111111111111 211221111111111111111 212122111111111111...
result:
ok Correct. (200 test cases)
Test #4:
score: -100
Wrong Answer
time: 0ms
memory: 3616kb
input:
100 5 1 2 5 4 3 2 4 5 3 1 6 6 1 5 2 4 3 1 4 5 6 2 3 3 2 1 3 1 2 3 5 5 3 4 2 1 1 2 3 5 4 10 5 9 4 2 6 10 7 8 3 1 1 3 4 10 5 7 2 9 8 6 10 5 9 10 7 8 3 4 6 2 1 2 7 4 3 10 9 5 8 1 6 8 1 7 4 6 3 5 2 8 3 5 1 4 6 8 7 2 4 2 3 4 1 1 4 2 3 7 3 7 4 6 2 1 5 5 6 7 3 4 1 2 8 2 1 4 7 8 3 6 5 5 2 7 4 3 1 8 6 4 3 2 ...
output:
112111111111111111111 22112211111111111111111111111111111 211111 21121111111111111111111 2222211222122111121112222211111111111111111111111111111111111111111111111111111111111111111111111 212221222222122221111111111111111111111111111111111111111111111111111111111111111111111111111111 2111112211111111...
result:
wrong answer On Case#5: After your operations, a[3] = 9 but a[3] = 4. (test case 5)