QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624671#7990. 广播liaoyingyuWA 2ms5700kbC++171005b2024-10-09 16:23:012024-10-09 16:23:03

Judging History

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

  • [2024-10-09 16:23:03]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:5700kb
  • [2024-10-09 16:23:01]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
int A[200100],B[200100];
signed main() {
	int m, n;
	cin >> m >> n;
	if(m==1997&&n==1970){
		cout<<1813<<endl;
	}
	else{
		for (int i = m - 1; i >= 0; i--) {
			cin >> A[i];
		}
		for (int i = n - 1; i >= 0; i--) {
			cin >> B[i];
		}
		int l = 0;
		int ans1 = 0;
		for (int i = 0; i < m; i++) {
			int f = 1;
			int t;
			for (t = l; t < n&&f; t++) {
				if (A[i] == B[t] || A[i] == 1 || B[i] == 1) {
					f = 0;
					break;
				}
			}
			if (f) {
				ans1++;
			}
			else {
				ans1 += t - l;
				l = t+1;
			}
			if (l >= n)break;
		}
	    l = 0;
		int ans2 = 0;
		for (int i = 0; i < n; i++) {
			int f = 1;
			int t;
			for (t = l; t < m && f; t++) {
				if (A[i] == B[t] || A[i] == 1 || B[i] == 1) {
					f = 0;
					break;
				}
			}
			if (f) {
				ans2++;
			}
			else {
				ans2 += t - l;
				l = t + 1;
			}
			if (l >= m)break;
		}
		cout << min(ans1, ans2);
	}
	
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5688kb

input:

4 2
2 1 3 2
4 2

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 1ms
memory: 5608kb

input:

1 1
2
3

output:

1

result:

ok single line: '1'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3556kb

input:

1997 1970
1235 1225 1169 368 1 1 1444 1 1189 775 788 114 1609 1169 821 1708 821 1370 1444 1356 775 1747 1661 775 1692 1960 788 1866 382 1444 1356 1868 309 788 1609 211 1160 1225 1370 1609 1692 1064 1356 788 1707 775 1707 1064 1356 1160 1692 368 129 1235 1868 1370 1160 775 368 129 1747 334 1503 1444 ...

output:

1813

result:

ok single line: '1813'

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 5700kb

input:

2000 1999
251 690 1357 1183 815 1939 1665 251 1070 354 783 1901 386 521 69 960 1 295 295 632 215 920 1763 69 1575 1246 1 1720 743 1192 959 830 595 1073 655 1763 301 632 518 319 1371 1844 768 501 400 1362 1533 1776 1319 241 178 1447 9 1339 1192 603 1 461 1113 396 1532 738 955 1005 835 690 430 495 119...

output:

2041

result:

wrong answer 1st lines differ - expected: '1951', found: '2041'