Submission #982965

# Submission time Handle Problem Language Result Execution time Memory
982965 2024-05-15T06:11:40 Z vjudge1 Strange Device (APIO19_strange_device) C++17
0 / 100
1810 ms 524288 KB
#include <bits/stdc++.h>
#define ft first
#define sd second
#define pb push_back
#define nl "\n"
#define int ll
typedef long long ll;
typedef long double ld;
using namespace std;
const int N = 1000100;

int n, a, b;
int l[N], r[N];

void solve() {
    cin >> n >> a >> b;
    int S = 0;
    for (int i = 0; i < n; i++) {
        cin >> l[i] >> r[i];
        S += (r[i] - l[i] + 1);
    }
    if (S <= 1000000) {
        map<int, int> mp;
        for (int i = 0; i < n; i++) {
            for (int j = l[i]; j <= r[i]; j++) {
                mp[j] = 1;
            }
        }
        for (auto j : mp) {
            if (j.sd == 0) continue;
            int t = j.ft;
            int k = 0;
            while(t + b * (k + 1) <= r[n - 1]) {
                k++;
                if (mp[t + b * k] == 1 && (b + 1) * k % a == 0) {
                    S--;
                    mp[t + b * k] = 0;
                    //cout << t << ' ' << t + b * k << nl;
                }
            }
        }
        cout << S << nl;
    }
}

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    while(T--) {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 1675 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Incorrect 1 ms 344 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Runtime error 1810 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 241 ms 44420 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 241 ms 44420 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 241 ms 44420 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 Incorrect 26 ms 5076 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Runtime error 1675 ms 524288 KB Execution killed with signal 9
3 Halted 0 ms 0 KB -