제출 #132376

#제출 시각아이디문제언어결과실행 시간메모리
132376dragonslayeritTeleporters (IOI08_teleporters)C++14
90 / 100
1020 ms40548 KiB
#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) 메시지

teleporters.cpp: In function 'int main()':
teleporters.cpp:25:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   scanf("%d %d",&N,&M);
   ~~~~~^~~~~~~~~~~~~~~
teleporters.cpp:27:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d",&xs[i<<1],&xs[i<<1|1]);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...