QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627752#7757. Palm Island53DawnsWA 1ms3596kbC++231.7kb2024-10-10 17:02:292024-10-10 17:02:31

Judging History

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

  • [2024-10-10 17:02:31]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3596kb
  • [2024-10-10 17:02:29]
  • 提交

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();
        }
        ans.push_back(1);
        f1();
     }
    while(1) {
        int ff = 1;
        for(int i = 1 ; i <= n ; i++) {
            if(mp[i] != b[i]) ff = 0;
            // cout << mp[i] << " ";
        }
        // cout << endl;
        if(ff == 0) {
            ans.push_back(1);
            f1();
        }else{
            break;
        }
    }
    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: 0
Wrong Answer
time: 1ms
memory: 3596kb

input:

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

output:

11111
1221111

result:

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