QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#632518 | #7757. Palm Island | tsai | WA | 1ms | 4028kb | C++14 | 848b | 2024-10-12 13:30:35 | 2024-10-12 13:30:39 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2005;
int n, a[N], b[N];
void solve(){
scanf("%d", &n);
for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
for(int i = 1; i <= n; i++){
int tmp; scanf("%d", &tmp);
b[tmp] = i;
}
deque<int>q;
for(int i = 1; i <= n; i++) q.push_back(b[a[i]]);
int rem = n % 2; n = n - n % 2;
for(int i = 1; i <= n; i+=2){
int fir = i, sec = i + 1;
while(q.front() != fir) q.push_back(q.front()), q.pop_front(), printf("1");
q.pop_front();
while(q.front() != sec) q.push_back(q.front()), q.pop_front(), printf("2");
q.pop_front();
printf("11"); q.push_back(1), q.push_back(2);
}
if(rem) printf("1");
}
int main(){
int t;
scanf("%d",&t);
while(t--){
solve();
if(t) printf("\n");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 1ms
memory: 3800kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
1111 1221111
result:
ok Correct. (2 test cases)
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 4028kb
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 21112211 1121112211 1122111122111 1122111222111 111111 11111 1121111 221111 11111 112111 1121112211 2111 12111 11111111 1121111 111221112211 1111 1111 11122111111 111221111 11221112211 11121112211 121112211 11122112111 1111 2111222111 11111111 111221111 211111 2111 111221112211 12111 112211111...
result:
wrong answer On Case#20: After your operations, a[1] = 5 but a[1] = 3. (test case 20)