QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#648329 | #7757. Palm Island | Lavender_Field# | WA | 0ms | 3848kb | C++20 | 888b | 2024-10-17 18:29:07 | 2024-10-17 18:29:07 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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)