QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#642224 | #7757. Palm Island | AuroraKelsey | WA | 0ms | 3636kb | C++14 | 959b | 2024-10-15 11:59:04 | 2024-10-15 11:59:05 |
Judging History
answer
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
using namespace std;
const int N = 10001;
int n;
int a[N], b[N], c[N];
map<int, int> mp;
bool check() {
for(int i=1;i<n;i++) {
if(mp[a[i]]>mp[a[i+1]])
return 0;
}
return 1;
}
int main() {
int t;
cin >> t;
while (t--) {
cin >> n;
for (int i = 1; i <= n; i++)
cin >> a[i];
for (int i = 1; i <= n; i++)
cin >> b[i], mp[b[i]] = i;
int tmp;
int i = 1, j = 2;
while (1) {
if (i > n) i -= n;
if (j > n) j -= n;
if (check()) break;
if (mp[a[i]] > mp[a[j]]) {
swap(a[i], a[j]);
cout << 2;
} else {
cout << 1;
}
i++;
j = i + 1;
}
cout << "\n";
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3636kb
input:
2 3 1 2 3 2 3 1 4 1 2 3 4 2 1 3 4
output:
22 2
result:
wrong answer On Case#1: After your operations, a[1] = 1 but a[1] = 2. (test case 1)