| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 742754 | speedyArda | 이상한 기계 (APIO19_strange_device) | C++14 | 4634 ms | 524288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int MAXN = 2e6+5;
map<ll, bool> visited;
vector< pair<ll, ll> > imp;
ll n, a, b;
int main()
{
/*for(ll a = 1; a <= 20; a++)
{
for(ll b = 1; b <= 20; b++)
{
map<pair<ll, ll> , bool> used;
ll time = 0;
while(!used[{(time + time / b) % a, time % b}])
{
used[{(time + time / b) % a, time % b}] = true;
time++;
}
cout << a << " " << b << " " << time << "\n";
}
}*/
cin >> n >> a >> b;
ll sum = 0;
ll big = 1;
map<pair<ll, ll>, bool> used;
ll time = 0;
while(!used[{(time + time / b) % a, time % b}])
{
used[{(time + time / b) % a, time % b}] = true;
time++;
}
big = time;
/*if(2e18 / b < a)
big = 2e18;
else
big = a * b;*/
for(int i = 1; i <= n; i++)
{
ll f, s;
cin >> f >> s;
if(s - f >= big - 1)
{
imp.push_back({0, 1});
imp.push_back({big - 1, 2});
} else
{
if(f % big <= s % big)
{
imp.push_back({f % big, 1});
imp.push_back({s % big, 2});
} else
{
imp.push_back({0, 1});
imp.push_back({s % big, 2});
imp.push_back({f % big, 1});
imp.push_back({big - 1, 2});
}
}
}
// cout << seg[0].sum << "\n";
sort(imp.begin(), imp.end());
ll cnt = 0;
ll ans = 0;
ll last = -1;
for(pair<ll, ll> e : imp)
{
//cout << ans << " " << cnt << " " << last << "\n";
if(last != -1 && cnt > 0)
{
ans += e.first - last;
if(!visited[last])
{
ans++;
visited[last] = true;
}
visited[e.first] = true;
}
if(e.second == 1)
{
cnt++;
last = e.first;
} else
{
cnt--;
last = e.first;
}
}
cout << ans << "\n";
}컴파일 시 표준 에러 (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... | ||||
