Submission #147912

#TimeUsernameProblemLanguageResultExecution timeMemory
147912starwh03문명 (KOI17_civilization)C++14
19 / 100
4 ms504 KiB
#include<bits/stdc++.h> using namespace std; int miku[2100]; int in[2100][2]; struct s { int d,a,b; bool operator<(s a){return a.d>d;} }; vector<s> cone; int uni(int i){return miku[i]<0?i:miku[i]=uni(miku[i]);} int dis(int a,int b){return abs(in[a][0]-in[b][0])+abs(in[a][1]-in[b][1]);} int main() { int n,m,mini=0; cin>>n>>m; for(int i=0;i<m;i++)cin>>in[i][0]>>in[i][1],miku[i]=-i-1; for(int i=0;i<m;i++)for(int j=i+1;j<m;j++)cone.push_back({dis(i,j),i,j}); sort(cone.begin(),cone.end()); for(int i=0;i<cone.size();i++) if(uni(cone[i].a)!=uni(cone[i].b))mini=cone[i].d,miku[uni(cone[i].a)]=uni(cone[i].b); cout<<mini/2; return 0; }

Compilation message (stderr)

civilization.cpp: In function 'int main()':
civilization.cpp:25:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<cone.size();i++)
                 ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...