# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
333138 | qwe854896 | Strange Device (APIO19_strange_device) | C++14 | 842 ms | 82256 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
#define endl '\n'
#define int long long
#define X first
#define Y second
using namespace std;
map <int, int> m;
signed main()
{
ios::sync_with_stdio(0);
cin.tie(0);
int n, A, B;
cin >> n >> A >> B;
int ans = 0, MOD = log10(A) - log10(__gcd(A, B+1)) + log10(B) > 18 ? (long long)(1e18+1) : A / __gcd(A, B+1) * B;
while (n--) {
int l, r;
cin >> l >> r;
int L = l % MOD, R = r % MOD;
if (L < R) m[L]++, m[R+1]--;
else if (L > R) m[L]++, m[MOD]--, m[0]++, m[R+1]--;
else if (l == r) m[L]++, m[L+1]--;
else ans = MOD;
}
int sum = 0, f = 1, l;
if (ans != MOD) {
for (auto seg:m) {
//cout << seg.X << ' ' << seg.Y << endl;
sum += seg.Y;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |