QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#288396#5650. Beppa and SwerChatSorting#WA 6ms3488kbC++14864b2023-12-22 16:36:102023-12-22 16:36:10

Judging History

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

  • [2023-12-22 16:36:10]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:3488kb
  • [2023-12-22 16:36:10]
  • 提交

answer

#include <iostream>
#include <vector>

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int t;
    cin >> t;

    while(t--){
        int n;
        cin >> n;

        vector<int> a(n), b(n);
        for(int i = 0; i < n; ++i){
            cin >> a[i];
            --a[i];
        }
        for(int i = 0; i < n; ++i){
            cin >> b[i];
            --b[i];
        }

        vector<int> pos(n), c(n);
        for(int i = 0; i < n; ++i){
            pos[a[i]] = i;
        }

        for(int i = 0; i < n; ++i){
            c[i] = pos[b[i]];
        }

        int mn = n + 1, ans = 0;
        for(int i = n - 1; i >= 0; --i){
            mn = min(mn, c[i]);
            if(c[i] > mn){
                ++ans;
            }
        }

        cout << ans << "\n";
    }
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 6ms
memory: 3488kb

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
2
2
0
1
1
1
2
2
1
2
1
1
2
2
2
2
2
2
2
2
3
3
3
3
3
3
0
1
1
1
2
2
1
2
1
1
2
2
2
2
2
2
2
2
3
3
3
3
3
3
1
2
2
2
3
3
1
2
1
1
2
2
2
2
2
2
2
2
3
3
3
3
3
3
2
3
2
2
3
3
2
3
2
2
3
3
2
2
2
2
2
2
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
3
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
4
...

result:

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