| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 983752 | pcc | 이상한 기계 (APIO19_strange_device) | C++17 | 443 ms | 70400 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define ll __int128_t
#define pll pair<ll,ll>
#define fs first
#define sc second
ll N,A,B;
ll cyc;
vector<pll> v;
ll gcd(ll a,ll b){
if(a<b)swap(a,b);
while(b){
a %= b;
swap(a,b);
}
return a;
}
ll get_cyc(){
ll re = B;
ll tmp = (B+1)%A;
if(!tmp)return B;
tmp = A/gcd(A,B+1);
return tmp*B;
}
int main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
long long buf;
cin>>buf;N = buf;
cin>>buf;A = buf;
cin>>buf;B = buf;
cyc = get_cyc();
for(int i = 0;i<N;i++){
long long l,r;
cin>>l>>r;
if(r-l+1>=cyc)v.push_back(pll(0,cyc-1));
else{
if(l%cyc>r%cyc){
v.push_back(pll(l%cyc,cyc-1));
v.push_back(pll(0,r%cyc));
}
else{
v.push_back(pll(l%cyc,r%cyc));
}
}
}
sort(v.begin(),v.end());
long long ans = 0;
ll rp = 0;
for(auto &i:v){
if(rp<i.fs){
ans += i.sc-i.fs+1;
rp = i.sc+1;
}
else{
ans += max((ll)0,i.sc-rp+1);
rp = max(rp,i.sc+1);
}
}
cout<<ans<<'\n';
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... | ||||
