이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int MAXN = 2e6+5;
map<ll, bool> visited;
vector< pair<ll, ll> > imp;
ll n, a, b;
int main()
{
cin >> n >> a >> b;
ll sum = 0;
ll big = 1;
if(2e18 / b < a)
big = 2e18;
else
big = a * b;
for(int i = 1; i <= n; i++)
{
ll f, s;
cin >> f >> s;
if(s - f >= big - 1)
{
imp.push_back({0, 1});
imp.push_back({big - 1, 2});
} else
{
if(f % big <= s % big)
{
imp.push_back({f % big, 1});
imp.push_back({s % big, 2});
} else
{
imp.push_back({0, 1});
imp.push_back({s % big, 2});
imp.push_back({f % big, 1});
imp.push_back({big - 1, 2});
}
}
}
// cout << seg[0].sum << "\n";
sort(imp.begin(), imp.end());
ll cnt = 0;
ll ans = 0;
ll last = -1;
for(pair<ll, ll> e : imp)
{
//cout << ans << " " << cnt << " " << last << "\n";
if(last != -1 && cnt > 0)
{
ans += e.first - last;
if(!visited[last])
{
ans++;
visited[last] = true;
}
visited[e.first] = true;
}
if(e.second == 1)
{
cnt++;
last = e.first;
} else
{
cnt--;
last = e.first;
}
}
cout << ans << "\n";
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp: In function 'int main()':
strange_device.cpp:13:8: warning: unused variable 'sum' [-Wunused-variable]
13 | ll sum = 0;
| ^~~
# | 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... |