제출 #590929

#제출 시각아이디문제언어결과실행 시간메모리
590929yutabi도시들 (IOI15_towns)C++14
25 / 100
16 ms384 KiB
#include "towns.h" #include <bits/stdc++.h> using namespace std; int hubDistance(int N, int sub) { int R=1000000007; int best=0; int d1=0; int d2=0; int d1_dist[200]; int d2_dist[200]; int hub_dist[200]; for(int i=1;i<N;i++) { int res=getDistance(0,i); if(res>best) { best=res; d1=i; } } d1_dist[0]=best; for(int i=1;i<N;i++) { if(i!=d1) { int res=getDistance(d1,i); if(res>best) { best=res; d2=i; } d1_dist[i]=res; } } d2_dist[d1]=best; for(int i=0;i<N;i++) { if(i!=d1 && i!=d2) { d2_dist[i]=getDistance(d2,i); } } bool dbl=0; for(int i=0;i<N;i++) { if(i!=d1 && i!=d2) { int sum=(d1_dist[i]+d2_dist[i]-d1_dist[d2])/2; if(R==max(d1_dist[i]-sum,d2_dist[i]-sum)) { dbl=1; } if(R>max(d1_dist[i]-sum,d2_dist[i]-sum)) { R=max(d1_dist[i]-sum,d2_dist[i]-sum); hub_dist[d1]=d1_dist[i]-sum; hub_dist[d2]=d2_dist[i]-sum; dbl=0; } } } int d1_count=0,d2_count=0; for(int i=0;i<N;i++) { if(i!=d1 && i!=d2) { int sum=(d1_dist[i]+d2_dist[i]-d1_dist[d2])/2; if(R<=d1_dist[i]-sum) { d1_count++; } else { d2_count++; } } } if(dbl && d1_count>=d2_count) { hub_dist[d1]=R; hub_dist[d2]=d1_dist[d2]-R; } else if(dbl) { hub_dist[d2]=R; hub_dist[d1]=d1_dist[d2]-R; } int grp_d1=1; int grp_d2=1; int grp_oth=0; for(int i=0;i<N;i++) { if(i!=d1 && i!=d2) { int sum=(d1_dist[i]+d2_dist[i]-d1_dist[d2])/2; if(d1_dist[i]-sum<hub_dist[d1]) { grp_d1++; } if(d1_dist[i]-sum==hub_dist[d1]) { grp_oth++; } if(d1_dist[i]-sum<hub_dist[d1]) { grp_d2++; } } } /*printf("%d %d\n",d1,d2); for(int i=0;i<N;i++) { printf("%d ",d1_dist[i]); } printf("\n"); for(int i=0;i<N;i++) { printf("%d ",d2_dist[i]); } printf("\n"); for(int i=0;i<N;i++) { printf("%d ",hub_dist[i]); } printf("\n");*/ if(grp_d1*2>N || grp_d2*2>N || grp_oth*2>N) { return -R; } return R; }

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

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