| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 926594 | TAhmed33 | 이상한 기계 (APIO19_strange_device) | C++98 | 1175 ms | 118676 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 ll2;
int main () {
ll n, a, b; cin >> n >> a >> b;
ll2 u = a; u *= b; u /= __gcd(a, b + 1);
vector <pair <ll, ll>> arr(n);
bool flag = 0;
for (auto &[x, y] : arr) {
cin >> x >> y;
flag |= y - x + 1 >= u;
}
if (flag) {
cout << (ll)u << '\n';
return 0;
}
vector <pair <ll2, ll2>> intervals;
for (auto [x, y] : arr) {
ll2 g = x % u, h = y % u;
if (g <= h) {
intervals.push_back({g, h});
} else {
intervals.push_back({g, u - 1});
intervals.push_back({0, h});
}
}
sort(intervals.begin(), intervals.end(), [] (pair <ll2, ll2> &x, pair <ll2, ll2> &y) {
return x.first == y.first ? x.second > y.second : x.first < y.first;
});
stack <pair <ll2, ll2>> dd;
for (auto &[x, y] : intervals) {
while (!dd.empty() && !(dd.top().first > y || dd.top().second < x)) {
x = min(x, dd.top().first); y = max(y, dd.top().second);
dd.pop();
}
dd.push({x, y});
}
ll2 sum = 0;
while (!dd.empty()) {
auto k = dd.top(); dd.pop();
sum += k.second - k.first + 1;
}
cout << ll(sum) << '\n';
}컴파일 시 표준 에러 (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... | ||||
