QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#639570#6786. Let's ChatLa5te2WA 1ms3780kbC++20798b2024-10-13 20:29:372024-10-13 20:29:41

Judging History

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

  • [2024-10-13 20:29:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3780kb
  • [2024-10-13 20:29:37]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<int, int>;
void solve() {
	int n, m, x, y;
	cin >> n >> m >> x >> y;
	std::vector<PII> a(x), b(y);
	for(int i = 0; i < x; i++) {
		cin >> a[i].first >> a[i].second;
	}
	for(int i = 0; i < y; i++) {
		cin >> b[i].first >> b[i].second;
	}
	ll sum = 0;
	int i = 0, j = 0;
	while(x > i && y > j) {
		int maxx = max(a[i].first, b[j].first);
		int minn = min(a[i].second, b[j].second);
		if(minn - maxx >= m - 1) {
			sum += (ll)minn - maxx - m + 2;
		}
		i += (a[i].second <= b[j].second);
		j += (a[i].second > b[j].second);
	}
	cout << sum << '\n';
	return;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	int t = 1;
	cin >> t;
	while(t--) solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2
10 3 3 2
1 3
5 8
10 10
1 8
10 10
5 3 1 1
1 2
4 5

output:

3
0

result:

ok 2 lines

Test #2:

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

input:

10
978378582 3619603 47 74
479986 5351489
5420308 7962369
11344514 15240567
28052230 34309090
69930493 71370103
96064381 113030999
131487830 167306026
201120250 210905551
215581108 218116928
239370726 250969994
251488779 259451325
264979602 268998475
277209414 278821999
294684099 297838279
300870315...

output:

100274055
27961009
84215883
74328688
30866581
39716676
1852548
45730425
51949024
97125369

result:

wrong answer 1st lines differ - expected: '119342838', found: '100274055'