제출 #151371

#제출 시각아이디문제언어결과실행 시간메모리
151371Bodo171도시들 (IOI15_towns)C++14
0 / 100
20 ms1144 KiB
#include "towns.h" #include <iostream> #include <algorithm> #include <vector> using namespace std; const int nmax=205; int n; int d[2][nmax]; int to[nmax],wh[nmax],sz[nmax]; vector<int> domin[nmax]; vector<int> cand; int eq(int x,int y) { return (to[x]+to[y]!=getDistance(x,y)); } bool checkHub(int x) { for(int i=0;i<n;i++) if(wh[i]==wh[x]) cand.push_back(i); int act=0,bal=0; for(auto it: cand) { if(bal==0) { act=it; bal++; } else { if(eq(act,it)) bal++; else { domin[act].push_back(it); bal--; } } sz[act]++; } int ap=0; for(auto it:cand) { if(sz[it]) { if(eq(act,it)) ap+=sz[it]-(int)domin[it].size(); else { for(auto oth: domin[it]) { ap+=eq(act,oth); } } } } return (ap<=n/2); } int hubDistance(int N, int sub) { int d1=0,R=0,mx=0; n=N; for(int i=0; i<n; i++) { d[0][i]=getDistance(0,i); if(d[0][i]>d[0][d1]) d1=i; } for(int i=0; i<n; i++) { d[1][i]=getDistance(d1,i); if(d[1][i]>mx) mx=d[1][i]; } int minDist=(1<<30); for(int i=0; i<n; i++) { to[i]=(d[0][i]+d[1][i]-d[0][d1])/2; wh[i]=(d[1][i]-to[i]); if(max(wh[i],mx-wh[i])<minDist) minDist=max(wh[i],mx-wh[i]); } vector<int> hubs; for(int i=0;i<n;i++) if(max(wh[i],mx-wh[i])==minDist) hubs.push_back(wh[i]); sort(hubs.begin(),hubs.end()); hubs.resize(unique(hubs.begin(),hubs.end())-hubs.begin()); bool ok=0; for(auto cen :hubs) { int mici=0,mari=0; for(int i=0;i<n;i++) { if(wh[i]<cen) mici++; if(wh[i]>cen) mari++; } if(mici<=n/2&&mari<=n/2) ok=checkHub(cen); } R=minDist; if(!ok) R=-R; return R; }

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

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:60:28: warning: unused parameter 'sub' [-Wunused-parameter]
 int hubDistance(int N, int sub) {
                            ^~~
#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...