QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#642224#7757. Palm IslandAuroraKelseyWA 0ms3636kbC++14959b2024-10-15 11:59:042024-10-15 11:59:05

Judging History

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

  • [2024-10-15 11:59:05]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-10-15 11:59:04]
  • 提交

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;
}


詳細信息

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)