이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define fastInput ios::sync_with_stdio(false); cin.tie(nullptr);
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pii;
typedef vector<pii> vp;
typedef vector<bool> vb;
typedef vector<vb> vvb;
ll A, B;
inline pii getTime(ll t) {
ll x = (t + (t / B)) % A;
ll y = t % B;
return { x,y };
}
inline void pushTime(pii p, ll mod, vp &points) {
if (p.first % mod <= p.second % mod) {
points.push_back({ p.first % mod, 1 });
points.push_back({ p.second % mod, -1 });
}
else {
points.push_back({ p.first % mod, 1 });
points.push_back({ mod, -1 });
points.push_back({ 0, 1 });
points.push_back({ p.second % mod, -1 });
}
}
int main() {
fastInput;
int n;
cin >> n >> A >> B;
ll mod = A*B;
if (mod < 0)mod = 1e18 + 7;
vp times(n);
vp points;
ll l, r;
for (int i = 0; i < n; i++) {
cin >> l >> r;
times[i] = { l,r + 1 };
pushTime(times[i], mod, points);
}
sort(points.begin(), points.end());
ll count = 0;;
int open = 0;
int last = -1;
for (int i = 0; i < points.size(); i++) {
open += points[i].second;
if (open == 0) {
if (last != -1) {
ll amount = points[i].first - last;
count += amount;
last = -1;
}
}
else {
if (last == -1) {
last = points[i].first;
}
}
}
cout << count;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
strange_device.cpp: In function 'int main()':
strange_device.cpp:57:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for (int i = 0; i < points.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... |