Submission #1031699

# Submission time Handle Problem Language Result Execution time Memory
1031699 2024-07-23T04:42:57 Z stdfloat Strange Device (APIO19_strange_device) C++17
0 / 100
3822 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int n;
    ll A, B;
    cin >> n >> A >> B;

    int L = 0;
    set<pair<int, int>> s;
    for (int i = 1; ; i++) {
        int x = (i + i / B) % A, y = i % B;
        if (s.find({x, y}) != s.end()) {
            L = i - 1;
            break;
        }

        s.insert({x, y});
    }

    vector<int> p(L + 1);
    while (n--) {
        int l, r;
        cin >> l >> r;

        if (L <= r - l + 1) {
            p[0]++;
            continue;
        }

        p[l % L]++; p[r % L + 1]--;

        if (l % L > r % L) p[0]++;
    }

    int cnt = 0;
    for (int i = 0; i < L; i++) {
        p[i] += p[i - 1];
        cnt += !!p[i];
    }

    cout << cnt;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1368 ms 329296 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 3822 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 174 ms 49280 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 292 ms 63176 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 292 ms 63176 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 292 ms 63176 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Runtime error 1575 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 344 KB Output is correct
2 Incorrect 1368 ms 329296 KB Output isn't correct
3 Halted 0 ms 0 KB -