QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#712001#7757. Palm Islandtassei903#WA 0ms3824kbC++231.1kb2024-11-05 14:15:252024-11-05 14:15:27

Judging History

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

  • [2024-11-05 14:15:27]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3824kb
  • [2024-11-05 14:15:25]
  • 提交

answer


#include <bits/stdc++.h>
#include <bits/extc++.h> 
using namespace std;
#define sz(x) (int)(x).size()
#define rep(i, l, r) for (int i = l; i < (r); i++)
#define rrep(i, l, r) for(int i = (int)(r)-1; i >= (int)(l); i--)
#define all(x) begin(x), end(x)

using ll = long long;
using vi = vector<int>;

using pii = pair<int, int>;

void solve() {
    std::cin.tie(0)->sync_with_stdio(0);

    
    int n;cin >> n;
    vector<int> a(n), b(n), c(n);
    rep(i, 0, n)cin >> a[i];
    rep(i, 0, n)cin >> b[i];
    rep(i, 0, n) {
        a[i]--;
        b[i]--;
        c[a[i]] = b[i];
    }
    // rep(i, 0, n) cout << c[i] << " ";cout << endl;
    string ans;
    rep(i, 0, n) {
        rep(j, 0, n-1) {
            if (c[j] > c[j+1]) {
                ans += "2";
                swap(c[j], c[j+1]);
            }
            else {
                ans += "1";
            }
        }
        ans += "1";
    }
    // rep(i, 0, n) cout << c[i] << " ";cout << endl;
    cout << ans << endl;
}

int main() {

    int T;cin >> T;
    while (T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

121211111
2111111111111111

result:

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