제출 #893542

#제출 시각아이디문제언어결과실행 시간메모리
893542Warinchai다리 (APIO19_bridges)C++14
0 / 100
160 ms8108 KiB
#include<bits/stdc++.h> using namespace std; vector<pair<int,pair<int,int> > >ed; int p[100005]; int sz[100005]; int fp(int x){return x==p[x]?x:p[x]=fp(p[x]);} void un(int a,int b){sz[fp(b)]+=sz[fp(a)],p[fp(a)]=fp(b);} int ans[100005]; vector<pair<int,pair<int,int> > >qr; int main(){ int n,m; cin>>n>>m; for(int i=1;i<=m;i++){ int a,b,c; cin>>a>>b>>c; ed.push_back({c,{a,b}}); } sort(ed.begin(),ed.end(),greater<pair<int,pair<int,int> > >()); for(int i=1;i<=n;i++)p[i]=i,sz[i]=1; int q; cin>>q; for(int i=0;i<q;i++){ int t,s,w; cin>>t>>s>>w; qr.push_back({w,{s,i}}); } sort(qr.begin(),qr.end(),greater<pair<int,pair<int,int> > >()); int cur=0; for(int i=0;i<q;i++){ int w=qr[i].first; int s=qr[i].second.first; int id=qr[i].second.second; while(cur<ed.size()&&ed[cur].first>=w){ un(ed[cur].second.first,ed[cur].second.second); cur++; } ans[id]=sz[fp(s)]; } for(int i=0;i<q;i++)cout<<ans[i]<<"\n"; }

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

bridges.cpp: In function 'int main()':
bridges.cpp:33:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |         while(cur<ed.size()&&ed[cur].first>=w){
      |               ~~~^~~~~~~~~~
#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...