| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 145362 | dolphingarlic | 이상한 기계 (APIO19_strange_device) | C++14 | 727 ms | 41496 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#pragma GCC Optimize("O3")
#define FOR(i, x, y) for (int i = x; i < y; i++)
#define MOD 1000000007
typedef long long ll;
using namespace std;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
ll n, a, b;
cin >> n >> a >> b;
vector<pair<ll, ll>> segs;
ll s = 0;
FOR(i, 1, n + 1) {
ll l, r;
cin >> l >> r;
segs.push_back({l, r});
s += r - l + 1;
}
ll l = segs[0].first;
ll r = segs[0].second;
ll k = a / __gcd(a, b + 1);
if (log(k) + log(b) >= 18 * log(10)) {
cout << s << '\n';
} else {
k *= b;
vector<pair<ll, ll>> intervals;
for (auto seg : segs) {
if (seg.second - seg.first + 1 >= k) {
cout << k << endl;
return 0;
}
if (seg.first % k > seg.second % k) {
intervals.push_back({0, seg.second % k});
intervals.push_back({seg.first % k, k - 1});
}
else {
intervals.push_back({seg.first % k, seg.second % k});
}
}
sort(intervals.begin(), intervals.end());
ll cur_start = intervals[0].first;
ll cur_end = intervals[0].second;
ll ans = 0;
FOR(i, 1, intervals.size()) {
if (intervals[i].first > cur_end + 1) {
ans += cur_end - cur_start + 1;
cur_start = intervals[i].first;
cur_end = intervals[i].second;
}
else {
cur_end = max(cur_end, intervals[i].second);
}
}
ans += cur_end - cur_start + 1;
cout << ans << '\n';
}
return 0;
}
컴파일 시 표준 에러 (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... | ||||
