QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#413803#5650. Beppa and SwerChatthesupermarketisgoingtome#AC ✓10ms4604kbC++17542b2024-05-18 08:58:432024-05-18 08:58:43

Judging History

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

  • [2024-05-18 08:58:43]
  • 评测
  • 测评结果:AC
  • 用时:10ms
  • 内存:4604kb
  • [2024-05-18 08:58:43]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
	cin.tie(nullptr)->sync_with_stdio(false);
	int t;
	cin >> t;
	while(t--){
		int n;
		cin >> n;
		vector<int>a(n+1);
		vector<int>b(n+1);
		for(int i = 1; i<=n; i++){
			cin >> a[i];
		}
		int ans = n;
		for(int i = 1; i<=n; i++){
			cin >> b[i];
		}
		int cur = n;
		for(int i = n; i>=1; i--){
			while(cur > 0 && a[cur]!=b[i]){
				cur--;
			}
			if(cur==0)break;
			cur--;
			ans--;
		}
		cout << ans << '\n';
	}
	return 0;
}

详细

Test #1:

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

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: 0
Accepted
time: 6ms
memory: 3616kb

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

ok 10000 lines

Test #3:

score: 0
Accepted
time: 10ms
memory: 4604kb

input:

1
100000
41422 70113 85344 94906 25198 64916 71447 39693 78122 98338 40109 37163 46252 83877 81512 57356 24501 42306 26535 82332 12922 81428 64009 42055 71277 23612 91457 58570 67109 31073 72273 48916 72454 96566 42033 24256 5282 17780 2547 29946 85089 54682 68113 93994 85959 5737 44097 80484 70536 ...

output:

44445

result:

ok single line: '44445'

Test #4:

score: 0
Accepted
time: 10ms
memory: 3740kb

input:

3
33333
25589 9697 2971 5417 1948 26447 16673 16765 176 28226 26009 3258 27183 25191 13904 27328 9368 30306 16319 32800 8764 2393 12762 24897 19219 12687 28892 14978 32284 14903 5704 7671 21481 5668 21084 8858 25380 9978 29124 17912 9579 28004 32472 12382 2609 20247 2926 18751 12895 3252 5146 4247 8...

output:

4
2
0

result:

ok 3 lines

Test #5:

score: 0
Accepted
time: 8ms
memory: 3532kb

input:

10000
3
3 2 1
1 3 2
13
5 2 13 10 7 8 3 11 12 4 6 9 1
4 11 9 5 1 8 7 2 3 10 13 12 6
2
1 2
2 1
4
1 2 3 4
3 1 2 4
4
1 2 4 3
2 4 1 3
12
3 2 10 9 7 1 8 12 6 11 5 4
11 3 7 8 5 9 2 4 1 12 6 10
12
4 10 9 1 11 5 2 12 8 6 7 3
5 1 9 2 6 12 4 7 8 10 11 3
5
5 4 1 3 2
5 4 1 3 2
17
13 11 7 9 10 1 14 3 17 5 2 16 4 ...

output:

1
10
1
1
2
11
9
0
15
4
5
0
1
14
0
0
3
12
0
1
0
5
7
13
15
9
14
3
1
11
9
3
0
15
3
3
4
6
14
7
15
17
3
12
12
6
5
16
6
1
13
10
8
17
15
7
17
12
10
16
7
4
7
3
0
0
13
0
2
0
4
8
10
9
13
11
5
3
13
4
5
9
10
15
10
12
0
6
5
6
13
11
8
0
6
11
12
9
16
7
7
13
4
5
0
8
4
8
3
10
7
15
14
11
9
10
11
0
5
0
13
15
11
4
11
0...

result:

ok 10000 lines

Test #6:

score: 0
Accepted
time: 10ms
memory: 3736kb

input:

3
33333
8211 19348 23684 26606 11091 1850 21084 32426 21040 15873 16665 17746 30101 3876 23696 31213 10419 1140 16314 14394 14723 2615 29063 2161 155 24593 2293 29623 22678 5847 10149 31365 30917 9033 27376 2057 7275 21524 7472 6649 29434 13941 23336 30088 385 21759 30361 32791 31033 32342 6323 969 ...

output:

33332
33330
33328

result:

ok 3 lines