답안 #217016

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
217016 2020-03-28T17:51:43 Z sevlll 이상한 기계 (APIO19_strange_device) C++17
65 / 100
961 ms 81952 KB
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

#define pb push_back
#define int long long
#define str string
using namespace std;
const int M = 1e9 + 7;

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n, a, b;
    cin >> n >> a >> b;
    vector<pair<int, int>> pr(n);
    for (int i = 0; i < n; i++) cin >> pr[i].first >> pr[i].second;
    int g = gcd(a, b + 1);
    a /= g;
    __int128_t num = a * b;
    vector<pair<__int128_t, int>> ev;
    for (auto p : pr) {
        int l = p.first, r = p.second;
        l %= num;
        r %= num;
        if (r < l) {
            ev.pb({l, 1});
            ev.pb({num, -1});
            ev.pb({0, 1});
            ev.pb({r + 1, -1});
        } else {
            ev.pb({l, 1});
            ev.pb({r + 1, -1});
        }
    }
    sort(ev.begin(), ev.end());
    int bal = 0;
    int last = 0;
    int ans = 0;
    for (auto p : ev) {
        int x = p.first, type = p.second;
        if (bal) {
            ans += (x - last);
        }
        last = x;
        bal += type;
    }
    cout << ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 11 ms 1660 KB Output is correct
3 Correct 12 ms 1660 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 11 ms 1660 KB Output is correct
17 Correct 83 ms 10216 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 5 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 256 KB Output is correct
2 Correct 5 ms 512 KB Output is correct
3 Correct 5 ms 512 KB Output is correct
4 Correct 5 ms 512 KB Output is correct
5 Correct 496 ms 81824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 718 ms 81904 KB Output is correct
3 Correct 782 ms 81824 KB Output is correct
4 Correct 724 ms 81856 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 718 ms 81904 KB Output is correct
3 Correct 782 ms 81824 KB Output is correct
4 Correct 724 ms 81856 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 757 ms 81800 KB Output is correct
7 Correct 743 ms 81952 KB Output is correct
8 Correct 732 ms 81824 KB Output is correct
9 Correct 921 ms 81824 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 718 ms 81904 KB Output is correct
3 Correct 782 ms 81824 KB Output is correct
4 Correct 724 ms 81856 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 72 ms 10344 KB Output is correct
7 Correct 77 ms 10216 KB Output is correct
8 Correct 78 ms 10344 KB Output is correct
9 Correct 77 ms 10216 KB Output is correct
10 Correct 71 ms 10216 KB Output is correct
11 Correct 73 ms 10216 KB Output is correct
12 Correct 72 ms 10216 KB Output is correct
13 Correct 79 ms 10216 KB Output is correct
14 Correct 81 ms 10344 KB Output is correct
15 Correct 87 ms 10216 KB Output is correct
16 Correct 79 ms 10216 KB Output is correct
17 Correct 75 ms 10216 KB Output is correct
18 Correct 742 ms 81760 KB Output is correct
19 Correct 730 ms 81856 KB Output is correct
20 Correct 936 ms 81824 KB Output is correct
21 Correct 88 ms 10216 KB Output is correct
22 Correct 68 ms 10216 KB Output is correct
23 Correct 211 ms 38624 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 78 ms 10216 KB Output is correct
3 Correct 79 ms 10344 KB Output is correct
4 Correct 961 ms 81824 KB Output is correct
5 Correct 81 ms 10216 KB Output is correct
6 Correct 83 ms 10216 KB Output is correct
7 Correct 86 ms 10344 KB Output is correct
8 Correct 85 ms 10216 KB Output is correct
9 Correct 79 ms 10216 KB Output is correct
10 Correct 85 ms 10288 KB Output is correct
11 Correct 85 ms 10216 KB Output is correct
12 Correct 75 ms 10216 KB Output is correct
13 Correct 85 ms 10344 KB Output is correct
14 Correct 940 ms 81828 KB Output is correct
15 Correct 84 ms 10216 KB Output is correct
16 Correct 734 ms 81952 KB Output is correct
17 Correct 760 ms 81952 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 11 ms 1660 KB Output is correct
3 Correct 12 ms 1660 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
5 Correct 4 ms 384 KB Output is correct
6 Correct 4 ms 384 KB Output is correct
7 Correct 4 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 4 ms 384 KB Output is correct
10 Correct 4 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 4 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 4 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 11 ms 1660 KB Output is correct
17 Correct 83 ms 10216 KB Output is correct
18 Correct 4 ms 384 KB Output is correct
19 Correct 4 ms 384 KB Output is correct
20 Incorrect 5 ms 384 KB Output isn't correct
21 Halted 0 ms 0 KB -