QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#536557#7757. Palm IslandXiaoretaW#WA 1ms3616kbC++201.5kb2024-08-29 14:32:322024-08-29 14:32:33

Judging History

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

  • [2024-08-29 14:32:33]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3616kb
  • [2024-08-29 14:32:32]
  • 提交

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];
    }
    
    int cur=1;
    F(i, 0, n) {
        while (nxt[a[0]] !=a[cur]){
            cout<<2;
            cur++;
            if(cur==n)cur=1;
        } 
        cout<<1;
        swap(a[0],a[cur]);
        cur++;
        if(cur==n)cur=1;
    }
    if(a[0]!=b[0]){
        cout<<1;
        while(a[cur]!=b[0]){
            cout<<1;
            cur++;
            if(cur==n)cur=1;
        }
    }
    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: 3524kb

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: 1ms
memory: 3616kb

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
21212121
221111111
2221121221211111
221212212111111
111111
11111
1212121111
221111
11111
21111
221111111
2111
211111
11111111
1212121111
22121212111
1111
1111
2112122121111
12121211
2212121211
2111111
121212111
2221221211211
1111
2121221211
12212112111
12121211
211111
2111
22121212111
211111
2...

result:

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