제출 #132366

#제출 시각아이디문제언어결과실행 시간메모리
132366dragonslayeritTeleporters (IOI08_teleporters)C++14
70 / 100
1078 ms41308 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++){ next[std::lower_bound(ys,ys+N*2,xs[i])-ys]= std::lower_bound(ys,ys+N*2,xs[i^1])-ys+1; } vis[N*2]=true; int score=explore(0); std::vector<int> cycles; for(int i=1;i<N*2;i++){ cycles.push_back(explore(i)); } std::sort(cycles.begin(),cycles.end(),std::greater<int>()); for(int i=0;i<std::min<int>(M,cycles.size());i++){ score+=cycles[i]; } printf("%d\n",score+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...