QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#536650#7757. Palm IslandXiaoretaW#WA 0ms3628kbC++202.0kb2024-08-29 15:26:312024-08-29 15:26:31

Judging History

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

  • [2024-08-29 15:26:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3628kb
  • [2024-08-29 15:26:31]
  • 提交

answer

#include <bits/stdc++.h>

#define debug(...) 42;
#ifdef LOCAL
#include "debug.h"
#endif

using namespace std;
#define V vector
#define fi first
#define se second
#define mp make_pair
#define sz(a) ((int)a.size())
#define all(a) a.begin(), a.end()
#define F(i, l, r) for (int i = l; i < r; ++i)
#define R(i, l, r) for (int i = r-1; i >= l; --i)
typedef long long LL;
typedef double DB;
typedef pair<int, int> PII;
template<typename T> bool setmin(T &a, T b) { return (a > b ? a = b, 1 : 0); }
template<typename T> bool setmax(T &a, T b) { return (a < b ? a = b, 1 : 0); }
// mt19937_64 rng {chrono::steady_clock::now().time_since_epoch().count()};

/* -------------Main code------------- */
void solve() {
    int n; cin >> n;
    V<int> a(n), b(n);
    F(i, 0, n) cin >> a[i];
    V<int> nxt(n + 1);
    F(i, 0, n) cin >> b[i];
    F(i, 0, n) {
        nxt[b[i]] = b[(i + 1) % n];
    }

    // auto ta = a;
    
    int cur=n-1;
    // string ans = "";
    F(i, 0, n) {
        while (nxt[a[cur]] !=a[0]){
            cout<<2;
            // ans += '2';
            cur++;
            if(cur==n)cur=1;
        } 
        cout<<1;
        // ans += '1';
        cur++;
        if(cur==n)cur=1;
        swap(a[0],a[cur]);
    }
    while(a[0]!=b[0]){
        cout<<1;
        // ans += '1';
        cur++;
        if(cur==n)cur=1;
        swap(a[0],a[cur]);
       
    }

    // //checker
    // a = ta;
    
    // for (char i : ans) {
    //     if (i == '1') {
    //         int t = a[0];
    //         a.erase(a.begin());
    //         a.push_back(t);
    //     } else {
    //         int t = a[1];
    //         a.erase(a.begin() + 1);
    //         a.push_back(t);
    //     }
    // }
    // // debug(a, b, ans);
    // assert(a == b);
    
    cout<<'\n';
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

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

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3612kb

input:

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

output:

1111
21111111

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3628kb

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
12111111
221111111
22122111111
22112111111
111111
11111
221211111
221111
11111
21111
221111111
2111
211111
11111111
221211111
212111
1111
1111
1221111
22121111
2121111
2111111
2212111
221211111
1111
21121111111
22212111111
22121111
211111
2111
212111
211111
22111111111
21221111
2221121111
2111...

result:

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