Submission #781599

# Submission time Handle Problem Language Result Execution time Memory
781599 2023-07-13T08:30:58 Z makanhulia Strange Device (APIO19_strange_device) C++17
0 / 100
470 ms 16992 KB
#include<bits/stdc++.h>
using namespace std;
#define ioss ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define pii pair<int, int>
#define fi first
#define se second
#define pb push_back
int n, a, b;
bool comp(pii a, pii b) {
    return (a.fi < b.fi || (a.fi == b.fi && a.se < b.se));
}
signed main() {
    ioss;
    cin >> n >> a >> b;
    int tmp = a*b;
    vector<pii> idx;
    for(int i = 0; i < n; i++) {
        int l, r; cin >> l >> r;
        l %= tmp, r %= tmp;
        if(r < l) r += tmp;
        idx.pb({l, r});
    }
    sort(idx.begin(), idx.end(), comp);

    int ans = 0;
    for(int i = 0; i < n; i++) {
        auto [l, r] = idx[i];
        if(i == 0) ans += (r-l)+1;
        else {
            auto [x, y] = idx[i-1];
            if(x <= l && y >= l) l = y+1;
            else if(x <= r && y >= r) r = x-1;
            else if(x <= l && y >= r) continue;
            ans += (r-l)+1;
        }
    }
    cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 4 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Incorrect 1 ms 340 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 386 ms 16816 KB Output is correct
3 Incorrect 394 ms 16992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 386 ms 16816 KB Output is correct
3 Incorrect 394 ms 16992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 386 ms 16816 KB Output is correct
3 Incorrect 394 ms 16992 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 39 ms 2460 KB Output is correct
3 Correct 44 ms 3680 KB Output is correct
4 Correct 470 ms 16940 KB Output is correct
5 Correct 46 ms 3524 KB Output is correct
6 Correct 42 ms 3764 KB Output is correct
7 Correct 48 ms 3732 KB Output is correct
8 Correct 48 ms 3772 KB Output is correct
9 Correct 42 ms 3764 KB Output is correct
10 Correct 46 ms 3268 KB Output is correct
11 Correct 60 ms 3324 KB Output is correct
12 Correct 33 ms 3780 KB Output is correct
13 Correct 42 ms 3240 KB Output is correct
14 Incorrect 442 ms 16960 KB Output isn't correct
15 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 4 ms 600 KB Output isn't correct
3 Halted 0 ms 0 KB -