이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#define wiwihorz
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC target("sse")
#pragma loop-opt(on)
#define rep(i, a, b) for(int i = a; i <= b; i ++)
#define rrep(i, a, b) for(int i = b; i >= a; i --)
#define all(x) x.begin(), x.end()
#define ceil(a, b) ((a + b - 1) / (b))
#define int long long int
#define lld long double
#define pii pair<int, int>
#define random mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count())
#define INF 1000000000000000001
#define MOD 1000000007
#define eps (1e-9)
using namespace std;
#ifdef wiwihorz
#define print(a...)cerr<<"Line "<<__LINE__<<":",kout("["+string(#a)+"] = ", a)
void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
void kout() { cerr << endl; }
template<class T1,class ... T2>void kout(T1 a,T2 ... e){cerr<<a<<" ",kout(e...);}
#else
#define print(...) 0
#define vprint(...) 0
#endif
#define x first
#define y second
namespace solver {
int n, A, B;
vector<pii> v, op;
void init_(int _n, int _A, int _B) {
n = _n, A = _A, B = _B;
v.assign(n + 1, {0, 0});
op.clear();
}
void solve() {
int tp = A / __gcd(A, B + 1), k, yes = 0;
if(tp > ceil(INF - 1, B)) k = INF;
else k = tp * B;
rep(i, 1, n) {
int L = v[i].x % k;
int R = v[i].y % k;
if(v[i].y - v[i].x >= k) {
cout << k << "\n";
return;
}
if(L > R) {
op.push_back({L, 1});
op.push_back({k, -1});
op.push_back({0, 1});
op.push_back({R + 1, -1});
}
else {
op.push_back({L, 1});
op.push_back({R + 1, -1});
}
}
sort(all(op));
int ans = 0, cnt = 0, cur = 0;
for(auto i : op) {
ans += (cnt > 0 ? i.x - cur : 0);
cnt += i.y;
cur = i.x;
}
cout << ans << "\n";
}
};
using namespace solver;
signed main() {
ios::sync_with_stdio(false), cin.tie(0);
int n, A, B;
cin >> n >> A >> B;
init_(n, A, B);
rep(i, 1, n) cin >> v[i].x >> v[i].y;
solve();
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp:5: warning: ignoring '#pragma loop ' [-Wunknown-pragmas]
5 | #pragma loop-opt(on)
|
strange_device.cpp:20:13: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
20 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
| ^~~~
strange_device.cpp:20:20: warning: use of 'auto' in parameter declaration only available with '-fconcepts-ts'
20 | void vprint(auto L,auto R){while(L<R)cerr<<*L<<" \n"[next(L) == R], ++L; }
| ^~~~
strange_device.cpp: In function 'void solver::solve()':
strange_device.cpp:38:36: warning: unused variable 'yes' [-Wunused-variable]
38 | int tp = A / __gcd(A, B + 1), k, yes = 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... |