QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#648329#7757. Palm IslandLavender_Field#WA 0ms3848kbC++20888b2024-10-17 18:29:072024-10-17 18:29:07

Judging History

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

  • [2024-10-17 18:29:07]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2024-10-17 18:29:07]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define MAXN 1000
int a[MAXN+5], b[MAXN+5], p[MAXN+5], vis[MAXN+5];
void solve() {
    int n; scanf("%d", &n);
    for(int i = 1; i <= n; ++i) scanf("%d", a+i);
    for(int i = 1; i <= n; ++i) scanf("%d", b+i), vis[b[i]] = i;
    // for(int i = 1; i <= n; ++i) printf("%d ", vis[i]); putchar('\n');
    for(int i = 1; i <= n; ++i) p[a[i]] = vis[i];
    // for(int i = 1; i <= n; ++i) printf("%d ", p[i]); putchar('\n');
    int ip = 1;
    for(int i = n-1; i >= 1; --i) {
        while( p[ip] != i ) {
            putchar('1');
            ip = ip % n + 1;
        }
        while( p[ip%n+1] != i+1 ) {
            putchar('2');
            swap(p[ip], p[ip%n+1]);
            ip = ip % n + 1;
        }
    }
    putchar('\n');
}
int main() {
    int T; scanf("%d", &T);
    while( T-- ) solve();
    return 0;
}

詳細信息

Test #1:

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

input:

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

output:

1111
11112111

result:

ok Correct. (2 test cases)

Test #2:

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

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:

111
112112111
1111111
12112211121111
122111111121111
122112111
11
1122111111
1112111
11
211
1112111111
11211
211
111122112211111111
2111111
111112111
1111
122112111
11112112211121111
12111111
22112111
1112112111
2111111
111122111211111111
1111
11222111111121111
111222111211111111
12111111
2221111111...

result:

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