# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
583303 | hibiki | Teleporters (IOI08_teleporters) | C++11 | 418 ms | 23580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define f first
#define s second
#define all(x) x.begin(),x.end()
int n,m;
pair<int,int> go[2000005];
bool pass[2000005];
int main()
{
scanf("%d %d",&n,&m);
for(int i = 0; i < 2000005; i++)
go[i] = {i + 1, 0};
for(int i = 0; i < n; i++)
{
int a,b;
scanf("%d %d",&a,&b);
go[a] = {b + 1, 1};
go[b] = {a + 1, 1};
}
int ans = 0;
priority_queue<int> pq;
pass[2000005 - 1] = true;
for(int i = 0; i < 2000005; i++)
{
if(pass[i]) continue;
int cnt = 0, nw = i;
while(!pass[nw])
{
pass[nw] = true;
cnt += go[nw].s;
nw = go[nw].f;
}
if(i == 0)
ans += cnt;
else
{
// printf("%d %d\n",i,cnt);
pq.push(cnt);
}
}
while(m > 0 && !pq.empty())
{
ans += pq.top() + 2;
pq.pop();
m--;
}
ans += (m / 2) * 4 + (m % 2);
printf("%d\n",ans);
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... |
# | 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... |
# | 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... |