# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
221784 | anonymous | Teleporters (IOI08_teleporters) | C++14 | 784 ms | 56256 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#define MAXN 1000005
#define fi first
#define se second
using namespace std;
int N, M, Ans, TP[MAXN][2], Pos[2*MAXN];
bool vis[2*MAXN]; //just visited endpoint [i]
vector <int> Cyc;
vector <pair<int,int> > L;
int main() {
//freopen("tpin.txt","r",stdin);
scanf("%d\n%d",&N,&M);
for (int i=1; i<=N; i++) {
scanf("%d %d",&TP[i][0], &TP[i][1]);
L.push_back({TP[i][0], i});
L.push_back({TP[i][1], i});
}
L.push_back({0,0});
sort(L.begin(), L.end());
for (int i=0; i<L.size(); i++) {
Pos[L[i].fi] = i;
}
for (int i=0; i<L.size(); i++) {
if (vis[i]) {continue;}
int sz = 0, cur = i;
while (!vis[cur]) {
vis[cur] = true;
if (cur == L.size()-1) {
Ans += sz;
break;
}
sz += 1;
if (L[cur+1].fi == TP[L[cur+1].se][0]) {
cur = Pos[TP[L[cur+1].se][1]];
} else {
cur = Pos[TP[L[cur+1].se][0]];
}
}
if (i) {Cyc.push_back(sz);}
}
sort(Cyc.begin(), Cyc.end());
while (M && Cyc.size()) {
Ans += Cyc.back() + 2;
M -=1;
Cyc.pop_back();
}
if (M%2) {Ans += 1;}
Ans += 4*(M/2);
printf("%d\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... |
# | 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... |