QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#473148#7757. Palm IslandyzhangWA 0ms3732kbC++141.0kb2024-07-11 22:27:542024-07-11 22:27:54

Judging History

你现在查看的是最新测评结果

  • [2024-07-11 22:27:54]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3732kb
  • [2024-07-11 22:27:54]
  • 提交

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 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];
    for(int i=2;i<=n;++i)
        ndp[b[i]]=b[i-1];
    for(int i=1;i<=n*(n-1);++i){
        if(ndp[nxt[bg]]!=0&&ndp[nxt[bg]]!=bg)
            op2();
        else 
            op1();
    }
    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;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

input:

2
3
1 2 3
2 3 1
4
1 2 3 4
2 1 3 4

output:

1111111
122111111111111

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3732kb

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
21211211111111
212211111111
212221211121111111111
2212122122222222222211
12222222222211
12222211
12122222222211
22111111111111
11111111
21111111
21221112222211
21122211
1211221
11111111111111111111111
12122222222211
222222222222111
2222221
111111111111
211212212112122121121111
1222222222221...

result:

wrong answer On Case#5: After your operations, a[3] = 1 but a[3] = 4. (test case 5)