# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
254840 | Lawliet | 이상한 기계 (APIO19_strange_device) | C++17 | 556 ms | 17492 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef pair<lli,lli> pll;
lli n, A, B;
vector<pll> sweep;
vector<pll> merged;
int main()
{
scanf("%lld %lld %lld",&n,&A,&B);
lli cycleSize = A/__gcd( A , B + 1 );
lli periodSize = 1000000000000000000LL;
if( cycleSize <= periodSize/B )
periodSize = cycleSize*B;
for(int i = 1 ; i <= n ; i++)
{
lli L, R;
scanf("%lld %lld",&L,&R);
if( R - L + 1 >= periodSize )
{
printf("%lld\n",periodSize);
return 0;
}
L %= periodSize; R %= periodSize;
if( L <= R ) sweep.push_back( { L , R } );
else
{
sweep.push_back( { 0 , R } );
sweep.push_back( { L , periodSize - 1 } );
}
}
sort( sweep.begin() , sweep.end() );
lli lastR = -2;
for(int i = 0 ; i < (int)sweep.size() ; i++)
{
if( lastR + 1 < sweep[i].first ) merged.push_back( sweep[i] );
else merged.back().second = sweep[i].second;
lastR = max( lastR , sweep[i].second );
}
lli ans = 0;
for(int i = 0 ; i < (int)merged.size() ; i++)
ans += merged[i].second - merged[i].first + 1;
printf("%lld\n",ans);
}
컴파일 시 표준 에러 (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... |