QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627834#7757. Palm Island53DawnsWA 1ms3844kbC++231.7kb2024-10-10 17:19:062024-10-10 17:19:06

Judging History

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

  • [2024-10-10 17:19:06]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3844kb
  • [2024-10-10 17:19:06]
  • 提交

answer

#include <bits/stdc++.h>
// #include <bits/extc++.h>
#pragma GCC optimize (1)
#pragma GCC optimize (2)
#pragma GCC optimize (3)
// #define int long long
#define IOS ios::sync_with_stdio(0),cin.tie(0)

// using namespace __gnu_pbds;
using namespace std;

const int N=2e5+10,M=1e6+10,mod=1e9+7;

int n;
map<int,int>mp;
void f1() {
    for(int i = 1 ; i <= n ; i++) {
        mp[i]--;
        if(mp[i] == 0) 
            mp[i] = n;
    }
}
void f2() {
    for(int i = 1 ; i <= n ; i++) {
        if(mp[i] == 1) continue;
        mp[i]--;
        if(mp[i] == 1) 
            mp[i] = n; 
    }
}
void sol(int cases) {
     cin >> n;
     std::vector<int> a(n+1);
     mp.clear();
     for(int i = 1 ; i <= n ; i++) {
            cin >> a[i];
            mp[a[i]] = i;
     }
     std::vector<int> b(n+1);
     for(int i = 1 ; i <= n ; i++) {
            cin >> b[i];
     }
     std::vector<int> ans;
     while(mp[b[1]] != 1) {
        f1();
        ans.push_back(1);
    }
    for(int i = 1 ; i <= n - 1; i++) {
        int u = mp[b[i]];
        int v = mp[b[i+1]];
        while(mp[b[i+1]] != 2) {
            ans.push_back(2);
            f2();
        }
        f1();
        ans.push_back(1);

    }
    // for(auto x : ans) {
    //     cout << x;
    // }
    // cout << endl;
    // for(int i = 1 ; i <= n ; i++) {
    //     cout << mp[i] << " ";
    // }
    // cout << endl;
    while(mp[b[1]] != 1) {
        f1();
        ans.push_back(1);
    }
    for(auto x : ans) {
        cout << x;
    }
    cout << endl;
}

signed main(){
    IOS;
    int t=1;
    cin>>t;
    for(int i=1;i<=t;++i){
        sol(i);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

1111
1221111

result:

ok Correct. (2 test cases)

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 3844kb

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
21212111
1121212111
1122122121111
1122121221211
111111
11111
1121111
221111
11111
112111
1121212111
2111
12111
11111111
1121111
111221212111
1111
1111
11122121121111
111221111
11221212111
11121212111
121212111
11122112122111
1111
2121221211
11121121111
111221111
211111
2111
111221212111
12111
...

result:

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