QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#627915#7757. Palm Island53DawnsWA 0ms3620kbC++231.1kb2024-10-10 17:37:522024-10-10 17:37:52

Judging History

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

  • [2024-10-10 17:37:52]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3620kb
  • [2024-10-10 17:37:52]
  • 提交

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;


void sol(int cases) {
    int n;
    cin >> n;
    map<int,int>mp;
    std::vector<int> ans;
    std::vector<int> a(n+1);
    std::vector<int> b(n+1);
    for(int i = 1; i <= n; i++) 
        cin >> a[i];
    for(int i = 1; i <= n; i++){
        cin >> b[i];
        mp[b[i]] = i;
    }
    for(int i = 1;i <= n; i++){
        for(int j = 1; j <= n - 1; j++){
            if(mp[a[j]] > mp[a[j + 1]]){
                ans.push_back(2);
                swap(a[j],a[j + 1]);
            }
            ans.push_back(1);
        }
        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: 0
Wrong Answer
time: 0ms
memory: 3620kb

input:

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

output:

21211111111
21111111111111111

result:

wrong answer On Case#1: The lenght of your output is 11(exceed n*n = 9). (test case 1)