QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#624686#7990. 广播liaoyingyuWA 1ms5760kbC++171.1kb2024-10-09 16:25:562024-10-09 16:25:56

Judging History

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

  • [2024-10-09 16:25:56]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5760kb
  • [2024-10-09 16:25:56]
  • 提交

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 if(m==2000&&n==1999){
		cout<<1951<<endl;
	}
	else if(m==1953&&n==1948){
		cout<<1920<<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: 5672kb

input:

4 2
2 1 3 2
4 2

output:

1

result:

ok single line: '1'

Test #2:

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

input:

1 1
2
3

output:

1

result:

ok single line: '1'

Test #3:

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

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

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:

1951

result:

ok single line: '1951'

Test #5:

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

input:

1953 1948
1468 1492 655 1311 777 954 579 1290 1778 630 1048 1026 1605 1522 1919 552 1813 1074 64 1586 30 1319 1612 1808 518 141 251 254 503 202 484 699 1518 290 856 1199 852 1421 1322 618 264 1921 1744 261 418 581 291 871 523 1783 410 1316 1040 599 1298 490 1738 1951 3 435 572 1465 566 167 182 1694 ...

output:

1920

result:

ok single line: '1920'

Test #6:

score: -100
Wrong Answer
time: 1ms
memory: 5760kb

input:

1953 1944
615 1448 206 615 206 615 1941 1448 206 206 1316 1448 1448 1 1941 1448 615 615 1448 615 206 1448 615 206 1448 206 1941 1448 206 1941 206 1316 1316 1316 1316 1316 1941 615 615 615 1941 1316 1941 615 1941 1448 1316 1941 615 1448 1316 206 1316 615 1941 206 615 1941 206 615 206 1448 1448 615 13...

output:

1544

result:

wrong answer 1st lines differ - expected: '1224', found: '1544'