# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
132376 | dragonslayerit | Teleporters (IOI08_teleporters) | C++14 | 1020 ms | 40548 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <map>
#include <vector>
#include <algorithm>
int xs[2000005];
int ys[2000005];
bool vis[2000005];
int next[2000005];
int explore(int a){
int len=0;
while(!vis[a]){
vis[a]=true;
a=next[a];
len++;
}
return len;
}
int main(){
int N,M;
scanf("%d %d",&N,&M);
for(int i=0;i<N;i++){
scanf("%d %d",&xs[i<<1],&xs[i<<1|1]);
}
std::copy(xs,xs+N*2,ys);
std::sort(ys,ys+N*2);
for(int i=0;i<N*2;i+=2){
int a=std::lower_bound(ys,ys+N*2,xs[i])-ys;
int b=std::lower_bound(ys,ys+N*2,xs[i^1])-ys;
next[a]=b+1;
next[b]=a+1;
}
vis[N*2]=true;
int score=explore(0);
std::vector<int> cycles;
for(int i=1;i<N*2;i++){
if(!vis[i]){
cycles.push_back(explore(i));
}
}
std::sort(cycles.begin(),cycles.end());
while(M>0&&cycles.size()){
score+=cycles.back()+2;
cycles.pop_back();
M--;
}
printf("%d\n",score+M/2*4+M%2);
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... |