| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 733007 | boyliguanhan | 이상한 기계 (APIO19_strange_device) | C++17 | 471 ms | 18640 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define int long long
int len;
bool merged[2000100];
struct range {
int l, r;
bool operator < (range against) {
return l < against.l;
}
};
vector<range> ranges;
int gcd(int a, int b) {
if(!b)
return a;
return gcd(b, a%b);
}
signed main() {
cin.sync_with_stdio(false);
cin.tie(nullptr);
int n, a, b;
cin >> n >> a >> b;
__int128_t temp = b;
temp*=a/gcd(a, b+1);
if(temp>1e18)
len = 2e18;
else
len = temp;
for(int i = 0; i < n; i++) {
int l, r;
cin >> l >> r;
if(r-l+1 >= len) {
cout << len << '\n';
return 0;
}
l%=len, r%=len;
if(l > r) {
ranges.push_back({l, len-1});
ranges.push_back({0, r});
} else {
ranges.push_back({l, r});
}
}
sort(ranges.begin(), ranges.end());
for(int i = 1; i < ranges.size(); i++) {
if(ranges[i].l <= ranges[i-1].r)
ranges[i].l = ranges[i-1].l, merged[i-1] = 1, ranges[i].r = max(ranges[i].r, ranges[i-1].r);
}
int ans = 0;
for(int i = 0; i < ranges.size(); i++)
if(!merged[i])
ans+=ranges[i].r-ranges[i].l+1;
cout << ans << '\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... | ||||
