# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
953878 | Vladth11 | Strange Device (APIO19_strange_device) | C++14 | 543 ms | 70368 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define debug(x) cerr << #x << " " << x << "\n"
#define debugs(x) cerr << #x << " " << x << " "
#pragma GCC optimize ("Ofast")
#pragma GCC target ("avx2")
using namespace std;
typedef long long ll;
typedef pair <ll, ll> pii;
const ll NMAX = 300001;
const int INF = 1e9;
const ll nrbits = 20;
const ll MOD = 998244353;
const ll VALMAX = 2e18;
signed main() {
#ifdef HOME
ifstream cin(".in");
ofstream cout(".out");
#endif // HOME
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
ll a, b;
cin >> n >> a >> b;
ll period;
ll g = __gcd(a, b + 1);
a /= g;
if(a >= VALMAX / b){
period = VALMAX;
}else{
period = a * b;
}
vector <pii> events;
while(n--){
ll l, r;
cin >> l >> r;
if(r - l + 1 >= period){
events.push_back({0, 1});
events.push_back({period, -1});
continue;
}
l %= period;
r %= period;
if(l <= r){
events.push_back({l, 1});
events.push_back({r + 1, -1});
}else{
events.push_back({0, 1});
events.push_back({r + 1, -1});
events.push_back({l, 1});
events.push_back({period, -1});
}
}
int s = 0;
ll total = 0;
sort(events.begin(), events.end());
for(int i = 0; i < events.size(); i++){
s += events[i].second;
if(events[i].first < period && (i < (events.size() - 1))){
if(s > 0)
total += (min(period, events[i + 1].first) - events[i].first);
}
}
cout << total;
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |