Submission #977103

# Submission time Handle Problem Language Result Execution time Memory
977103 2024-05-07T11:44:06 Z akacool445k Strange Device (APIO19_strange_device) C++14
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>
 
using namespace std;
#define ff first
#define ss second
#define int long long
const long long mod = 1e9 + 7;
const long long shrek = (1 << 30);
int gcd(int a, int b) {
	if(a == 0) return b;
	if(b == 0) return a;
	return gcd(b % a, a);
}
signed main() {
    int A, B, n;
    cin >> n >> A >> B;
    int k =  gcd(A, B + 1);
    double fuk = 1.0 * A * B / k;
    int gay = 1e18;
    if(fuk <= 1e18) gay = B * A / k;
    set<pair<int, int>> v;
    bool cmd = 0;
    for(int i = 0; i < n; i++) {
        int x, y;
        cin >> x >> y;
        if(y - x + 1 >= gay) {
            cmd = 1;
            continue;
        } else {
            x = x % gay;
            y = y % gay;
            if(x <= y) {
                v.insert({x, y});
            } else {
                v.insert({0, y});
                v.insert({x, gay - 1});
            }
        }
    }
    v.insert({2e18, 2e18});
    if(cmd == 1) {
        cout << gay << '\n';
    }
    int ans = 0;
    int l, r;
    l = (*v.begin()).ff; 
    r = l;
    for(auto x : v) {
        if(r < x.ff) {
            ans = ans + r - l + 1;
            l = x.ff;
            r = x.ss;
        }
        r = max(r, x.ss);
    }
    cout << ans << '\n';
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -