QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#864745#5650. Beppa and SwerChatjuancs#WA 7ms3712kbC++201.0kb2025-01-20 23:02:082025-01-20 23:02:09

Judging History

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

  • [2025-01-20 23:02:09]
  • 评测
  • 测评结果:WA
  • 用时:7ms
  • 内存:3712kb
  • [2025-01-20 23:02:08]
  • 提交

answer

#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

using namespace std;

typedef vector<int>vi;
typedef pair<int, int> ii;
typedef tree<int,null_type,less<int>, rb_tree_tag, 
    tree_order_statistics_node_update> ordered_set;

#define el '\n'
#define pb push_back
#define all(a) a.begin(), a.end()
#define sz(a) (int)a.size()
#define forn(i,n) for(int i = 0; i < n;++i)
#define pb push_back
#define db(x) cerr << #x << ' ' << x << el;

void solve(){
    int n;
    cin>>n;
    vi a(n), b(n+1);
    forn(i,n)cin>>a[i];
    forn(i,n) {int num; cin>>num; b[num] = i;}

    int ans = 0;
    vi lis;
    forn(i,n){
        int x = b[a[i]];
        int it = lower_bound(all(lis), x) - lis.begin();
        if(it == sz(lis)) lis.pb(x);
        else lis[it] = x;
    }
    cout<<n-sz(lis)<<el;
}

int main(){

    ios_base::sync_with_stdio(0);
    cin.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: 3712kb

input:

4
5
1 4 2 5 3
4 5 1 2 3
6
1 2 3 4 5 6
1 2 3 4 5 6
8
8 2 4 7 1 6 5 3
5 6 1 4 8 2 7 3
1
1
1

output:

2
0
4
0

result:

ok 4 lines

Test #2:

score: -100
Wrong Answer
time: 7ms
memory: 3712kb

input:

10000
2
2 1
2 1
2
2 1
1 2
3
3 1 2
3 1 2
3
2 3 1
2 1 3
3
1 3 2
3 1 2
3
1 2 3
3 1 2
3
2 3 1
3 1 2
3
3 2 1
1 2 3
4
3 2 4 1
3 2 4 1
4
1 4 2 3
1 4 3 2
4
4 2 3 1
4 3 2 1
4
4 1 2 3
4 3 1 2
4
2 1 3 4
2 3 4 1
4
3 1 2 4
3 4 2 1
4
3 4 2 1
4 3 2 1
4
3 1 4 2
1 3 2 4
4
2 4 1 3
1 2 4 3
4
4 1 3 2
2 4 1 3
4
3 1 4 2
...

output:

0
1
0
1
1
1
1
2
0
1
1
1
1
2
1
2
1
1
2
2
1
2
2
2
2
2
1
2
2
2
2
3
0
1
1
1
1
2
1
2
1
1
2
2
1
2
2
2
2
2
1
2
2
2
2
3
1
2
2
2
2
3
1
2
1
1
2
2
2
2
2
2
2
2
2
3
2
2
3
3
1
2
2
2
2
3
2
3
2
2
3
3
2
2
2
2
2
2
2
3
3
3
3
3
1
2
2
2
2
3
2
3
2
2
3
3
2
3
3
3
3
3
2
3
3
3
3
3
1
2
2
2
2
3
2
3
2
2
3
3
2
3
3
3
3
3
2
3
3
3
...

result:

wrong answer 4th lines differ - expected: '2', found: '1'