이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
#define lli unsigned long long int
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "
#define rep(i,a,b) for(int i = (a); i <= (b); i++)
#define repa(i,a,b) for(int i = (a); i >= (b); i--)
#define LIM (1ll << 60)
lli a,b,n,cont,x,y,mult,ini,res,k;
vector<pair<lli,lli> > orden;
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> a >> b;
k = __gcd(a,b+1);
//debug(k);
k = a/k;
if (LIM/k < b) mult = LIM;
else mult = k*b;
rep(i,1,n) {
cin >> x >> y;
if (x == y) {
x %= mult;
orden.push_back({x,1});
orden.push_back({x,2});
continue;
}
k = y-x;
if (k >= mult) {
orden.push_back({0,1});
orden.push_back({mult-1,2});
continue;
}
x %= mult;
y %= mult;
if (x >= y) {
orden.push_back({0,1});
orden.push_back({mult-1,2});
}
orden.push_back({x,1});
orden.push_back({y,2});
}
sort(orden.begin(), orden.end());
ini = -1;
cont = 0;
res = 0;
for (auto act:orden) {
if (act.second == 1) {
cont++;
if (ini == -1) ini = act.first;
}
else cont--;
if (cont == 0) {
res += (act.first - ini) + 1;
ini = -1;
}
}
cout << res;
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp: In function 'int main()':
strange_device.cpp:7:39: warning: comparison of integer expressions of different signedness: 'int' and 'long long unsigned int' [-Wsign-compare]
7 | #define rep(i,a,b) for(int i = (a); i <= (b); i++)
| ^
strange_device.cpp:28:5: note: in expansion of macro 'rep'
28 | rep(i,1,n) {
| ^~~
strange_device.cpp:65:21: warning: comparison of integer expressions of different signedness: 'long long unsigned int' and 'int' [-Wsign-compare]
65 | if (ini == -1) ini = act.first;
| ~~~~^~~~~
# | 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... |