Submission #322567

# Submission time Handle Problem Language Result Execution time Memory
322567 2020-11-14T23:15:11 Z arbor Strange Device (APIO19_strange_device) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
using namespace std;
using ll = long long;
using pii = pair<int, int>;
const int MN = 1e5 + 5;
using ull = unsigned long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    ull n, a, b; cin >> n >> a >> b;
    ull p = a / gcd(a, b + 1) * b;
    vector<pair<ull, ull>> v;
    for (int i = 0; i < n; i++) {
        ull l, r; cin >> l >> r;
        l %= p, r %= p;
        if (l > r) v.emplace_back(0, r), v.emplace_back(l, p - 1);
        else v.emplace_back(l, r);
    }
    v.emplace_back(p, p - 1);
    sort(all(v));
    ull ans = 0;
    for (int i = 0; i < v.size();) {
        int j = i;
        for (; v[i].second >= v[j].second && j < v.size(); j++);
        ans += v[i].second - v[i].first + 1;
        v[j].first = max(v[j].first, v[i].second + 1);
        i = j;
    }
    cout << ans << '\n';
    return 0;
}

Compilation message

strange_device.cpp: In function 'int main()':
strange_device.cpp:12:17: error: 'gcd' was not declared in this scope
   12 |     ull p = a / gcd(a, b + 1) * b;
      |                 ^~~
strange_device.cpp:14:23: warning: comparison of integer expressions of different signedness: 'int' and 'ull' {aka 'long long unsigned int'} [-Wsign-compare]
   14 |     for (int i = 0; i < n; i++) {
      |                     ~~^~~
strange_device.cpp:23:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long unsigned int, long long unsigned int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   23 |     for (int i = 0; i < v.size();) {
      |                     ~~^~~~~~~~~~
strange_device.cpp:25:48: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long unsigned int, long long unsigned int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |         for (; v[i].second >= v[j].second && j < v.size(); j++);
      |                                              ~~^~~~~~~~~~