QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#184108#6786. Let's Chatucup-team004#AC ✓1ms3448kbC++20911b2023-09-20 12:55:392023-09-20 12:55:39

Judging History

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

  • [2023-09-20 12:55:39]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:3448kb
  • [2023-09-20 12:55:39]
  • 提交

answer

#include <bits/stdc++.h>

using i64 = long long;

void solve() {
    int n, m, x, y;
    std::cin >> n >> m >> x >> y;
    
    std::vector<std::pair<int, int>> a(x), b(y);
    int ans = 0;
    for (int i = 0; i < x; i++) {
        int l, r;
        std::cin >> l >> r;
        a[i] = {l, r};
    }
    for (int i = 0; i < y; i++) {
        int l, r;
        std::cin >> l >> r;
        b[i] = {l, r};
    }
    for (int i = 0; i < x; i++) {
        for (int j = 0; j < y; j++) {
            int l = std::max(a[i].first, b[j].first);
            int r = std::min(a[i].second, b[j].second);
            ans += std::max(0, r - l + 1 - m + 1);
        }
    }
    std::cout << ans << "\n";
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    int t;
    std::cin >> t;
    
    while (t--) {
        solve();
    }
    
    return 0;
}

这程序好像有点Bug,我给组数据试试?

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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:

119342838
35153801
144883974
82675908
33074404
41458373
4138220
69656059
71436009
110675349

result:

ok 10 lines