Submission #217044

# Submission time Handle Problem Language Result Execution time Memory
217044 2020-03-28T18:26:47 Z sevlll Strange Device (APIO19_strange_device) C++17
0 / 100
5000 ms 81756 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 int2 __int128_t
#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;
    int2 g = gcd(a, b + 1);
    a /= g;
    int2 num = a * b;
    vector<pair<int2, int2>> ev;
    for (auto p : pr) {
        int2 l = p.first, r = p.second;
        if (r - l >= num - 1) {
            cout << (int) num;
            return 0;
        }
        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());
    int2 bal = 0;
    int2 last = 0;
    int ans = 0;
    for (auto p : ev) {
        for (auto p : ev) {
            int2 x = p.first;
            int2 type = p.second;
            if (bal) {
                ans += (x - last);
            }
            last = x;
            bal += type;
        }
        cout << ans;
    }
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:63:15: warning: variable 'p' set but not used [-Wunused-but-set-variable]
     for (auto p : ev) {
               ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 487 ms 1660 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Incorrect 5 ms 384 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 10 ms 512 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Execution timed out 5059 ms 81756 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Execution timed out 5059 ms 81756 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Execution timed out 5059 ms 81756 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Execution timed out 5054 ms 10216 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Incorrect 487 ms 1660 KB Output isn't correct
3 Halted 0 ms 0 KB -