이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef __int128 asdf;
typedef pair<asdf, asdf> p;
ll _n, _a, _b;
asdf n, a, b, c, sz;
void print(__int128 x){
string s;
while(x){
s += (char)(x%10 + '0'); x /= 10;
}
reverse(s.begin(), s.end());
cout << s;
}
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
cin >> _n >> _a >> _b;
n = _n, a = _a, b = _b;
sz = a / __gcd(a, b+1) * b;
vector<p> v;
for(int i=0; i<n; i++){
ll _l, _r; cin >> _l >> _r;
asdf l, r; l = _l, r = _r;
if(r-l+1 > sz){
print(sz); return 0;
}
l %= sz, r %= sz;
if(l <= r) v.emplace_back(l, r);
else v.emplace_back(l, sz-1), v.emplace_back(0, r);
}
sort(v.begin(), v.end());
asdf ans = 0;
for(int i=0; i<v.size(); i++){
int j = i; asdf now = v[i].second;
while(j < v.size() && v[j].first <= now){
now = max(now, v[j].second); j++;
}
ans += now - v[i].first + 1;
i = j - 1;
}
print(ans);
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp: In function 'int main()':
strange_device.cpp:39:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i=0; i<v.size(); i++){
~^~~~~~~~~
strange_device.cpp:41:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
while(j < v.size() && v[j].first <= now){
~~^~~~~~~~~~
# | 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... |