제출 #1020825

#제출 시각아이디문제언어결과실행 시간메모리
1020825boyliguanhanTeleporters (IOI08_teleporters)C++17
100 / 100
583 ms28316 KiB
#include<bits/stdc++.h> using namespace std; int go[2000100],tele[2000100],st[2000100],sz; bitset<2000100>vis; int docycle(int n){ int x=0; while(!vis[n]) x++,vis[n]=1,n=go[n]; return x; } int main(){ int n,m; cin>>n>>m; for(int i=1;i<=n;i++){ int x,y; cin>>x>>y; tele[x]=y; tele[y]=x; st[sz++]=x; st[sz++]=y; } sz++; st[sz++]=2e6+1; tele[(int)2e6+1]=2e6+1; sort(st,st+sz); for(int i=0;i<sz;i++){ if(st[i]>2e6)break; go[st[i]]=tele[st[i+1]]; } int x=0,y=0; while(x<=2e6) y++,vis[x]=1,x=go[x]; priority_queue<int>pq; for(int i=0;i<sz;i++) if(!vis[st[i]]) pq.push(docycle(st[i])); if(m>=pq.size()) cout<<(n+m)*2-(n+m&1); else { while(m--) y+=2+pq.top(),pq.pop(); cout<<y-1; } }

컴파일 시 표준 에러 (stderr) 메시지

teleporters.cpp: In function 'int main()':
teleporters.cpp:38:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::priority_queue<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     if(m>=pq.size())
      |        ~^~~~~~~~~~~
teleporters.cpp:39:25: warning: suggest parentheses around '+' in operand of '&' [-Wparentheses]
   39 |         cout<<(n+m)*2-(n+m&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...