QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#595126#7757. Palm Islandforget-star#WA 1ms7736kbC++141.3kb2024-09-28 12:39:062024-09-28 12:39:07

Judging History

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

  • [2024-09-28 12:39:07]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7736kb
  • [2024-09-28 12:39:06]
  • 提交

answer

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

#define ll long long

using namespace std;

const int N=1e6+7,inf = 2e9+77777777;

int read()
{
    int a = 0,x = 1;char ch = getchar();
    while(ch > '9' || ch < '0') {if(ch == '-') x = -1;ch = getchar();}
    while(ch >= '0' && ch <= '9') {a = a*10 + ch-'0';ch = getchar();}
    return a*x;
}

int n,b[N],p[N],o,ans[N];
struct node{
    int l,r,num;
}a[N];
int nxt() {return a[a[o].r].num;}
void op1() {o = a[o].r;}
void op2() 
{
    int xt1 = a[o].r;
    swap(a[o].num,a[xt1].num);
    op1();
}

void solve()
{
    n = read();o = 0;int cnt=  0;
    for(int i = 0;i < n;i ++) a[i].num = read(),a[i].l = (i+n-1)%n,a[i].r = (i+1)%n;
    for(int i = 0;i < n;i ++) b[i] = read();
    for(int i = 0;i < n;i ++) p[b[i]] = b[(i+1)%n];
    for(int i = 1;i <= n;i ++) {
        if(nxt() != p[a[o].num]) {
            ans[++cnt] = 2;
            op2();
        } else {
            ans[++cnt] = 1;
            op1();
        }
    }
    while(a[o].num != b[0]) {
        ans[++cnt] = 1;
        op1();
    }
    for(int i= 1;i <= cnt;i ++) printf("%d",ans[i]);
    puts("");
}

int main()
{
    // freopen("in.in","r",stdin);freopen("out.out","w",stdout);
    int T = read();
    while(T --) solve();
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 7736kb

input:

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

output:

1111
2111

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 7680kb

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:

11111
21211
22111
222111
221211
111111
11111
12121
221111
11111
21111
22111
2111
211
11111111
12121
2212
1111
1111
211211111
1212
22121
2111111
121211
2221211
1111
212121
122121
1212
211111
2111
2212
211
221111
22112
222121
211
22111
2211
1111111
2211111
11111
2111111
12121
221111
22212111
2111
1111...

result:

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