이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
long long gcd(long long x, long long y)
{
if (x == 0)
return y;
return gcd(y % x, x);
}
long long lca(long long x, long long y)
{
return x / gcd(x, y) * y;
}
long long n, x, y;
long long t;
vector<pair<long long, int> > v;
void ubd(long long l, long long r)
{
v.push_back(m_p(l, 1));
v.push_back(m_p(r + 1, -1));
}
int main()
{
#ifdef SOMETHING
freopen("input.txt", "r", stdin);
#endif // SOMETHING
cin >> n >> x >> y;
t = x / gcd(y + 1, x) * y;
while (n--)
{
long long l, r;
cin >> l >> r;
if (l / t == r / t)
ubd(l % t, r % t);
else if (l / t == r / t - 1)
{
ubd(0, r % t);
ubd(l % t, t - 1);
}
else
{
ubd(0, t - 1);
}
}
sort(v.begin(), v.end());
long long ans = 0;
int p = 0;
for (int i = 0; i < v.size(); ++i)
{
p += v[i].second;
if (p > 0)
ans += (v[i + 1].first - v[i].first);
}
cout << ans << endl;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp: In function 'int main()':
strange_device.cpp:54:23: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for (int i = 0; i < v.size(); ++i)
~~^~~~~~~~~~
# | 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... |