Submission #142541

# Submission time Handle Problem Language Result Execution time Memory
142541 2019-08-09T13:35:49 Z imeimi2000 Strange Device (APIO19_strange_device) C++17
Compilation error
0 ms 0 KB
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <cstdlib>
 
using namespace std;
typedef long long llong;
typedef pair<llong, llong> pll;
 
const llong inf = 1e18 + 1;
llong mul(llong x, llong y) {
    llong r = 0;
    while (y) {
        if (x > inf) return inf;
        if (y & 1) r += x;
        if (r > inf) return inf;
        x += x;
        y >>= 1;
    }
    return r;
}
 
llong gcd(llong x, llong y) {
    for (; y; swap(x, y)) x %= y;
    return x;
}
 
set<pll> sp;
void add(llong s, llong e, llong M) {
    if (M <= e - s + 1) {
        printf("%lld\n", M);
        exit(0);
    }
    s %= M;
    e %= M;
    if (e < s) {
        add(s, M - 1, M);
        add(0, e, M);
        return;
    }
    while (1) {
        auto it = sp.lower_bound(pll(e + 2, -1));
        if (it == sp.begin()) break;
        --it;
        if (it->second + 1 < s) break;
        s = min(s, it->first);
        e = max(e, it->second);
        sp.erase(it);
    }
    sp.emplace(s, e);
}
 
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n;
    llong A, B;
    cin >> n >> A >> B;
    llong G = gcd(A, B + 1);
    llong M = mul(A / G, B);
    for (int i = 0; i < n; ++i) {
        llong L, R;
        cin >> L >> R;
        add(L, R, M);
    }
    llong ans = 0;
    for (pll i : sp) ans += i.second - i.first + 1;
    printf("%lld\n", ans);
    return 0;
}

Compilation message

strange_device.cpp:6:1: error: stray '\302' in program
  
 ^
strange_device.cpp:6:2: error: stray '\240' in program
  
  ^
strange_device.cpp:10:1: error: stray '\302' in program
  
 ^
strange_device.cpp:10:2: error: stray '\240' in program
  
  ^
strange_device.cpp:23:1: error: stray '\302' in program
  
 ^
strange_device.cpp:23:2: error: stray '\240' in program
  
  ^
strange_device.cpp:28:1: error: stray '\302' in program
  
 ^
strange_device.cpp:28:2: error: stray '\240' in program
  
  ^
strange_device.cpp:53:1: error: stray '\302' in program
  
 ^
strange_device.cpp:53:2: error: stray '\240' in program
  
  ^