QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#598718#7757. Palm IslandSunlight9WA 0ms3572kbC++201.2kb2024-09-28 23:07:512024-09-28 23:07:52

Judging History

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

  • [2024-09-28 23:07:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3572kb
  • [2024-09-28 23:07:51]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

void solve() {
    int n;
    cin >> n;

    vector<int> a(n + 1), b(n + 1), id(n + 1), c(n + 1);
    for (int i = 1; i <= n; ++i) {
        cin >> a[i];
        id[a[i]] = i;
    }
    deque<int> q;
    for (int i = 1; i <= n; ++i) {
        cin >> b[i];
        c[i] = id[b[i]];
//        cerr << c[i] << " \n"[i == n];
        q.push_back(c[i]);
    }

    while (q.front() != n) {
        auto t = q.front();
        q.pop_front();
        q.push_back(t);
        cout << "1";
    }
    q.push_back(q.front());
    q.pop_front();
    cout << "1";

    for (int i = n - 1; i >= 1; --i) {
        while (q.front() != i) {
            q.push_back(q.front());
            q.pop_front();
            cout << "1";
        }
        q.pop_front();
        while (q.front() != i + 1) {
            q.push_back(q.front());
            q.pop_front();
            cout << "2";
        }
        q.push_front(i);
//        cout << "11";
    }
    cout << "\n";
}

int main() {
    cin.tie(nullptr) -> sync_with_stdio(false);

    int _;
    cin >> _;
    while (_--) solve();

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3572kb

input:

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

output:

11111
111111112111

result:

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