제출 #784294

#제출 시각아이디문제언어결과실행 시간메모리
784294Lyrically도시들 (IOI15_towns)C++17
25 / 100
12 ms724 KiB
#include<bits/stdc++.h> #include "towns.h" using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define rep1(i,n) for(int i=1;i<=n;i++) int hubDistance(int n,int subtsk) { if(subtsk==1||subtsk==2||subtsk==4) { int dis[115][115]={0}; int Max=0,id=-1; rep1(i,n-1) { int x=getDistance(0,i); dis[0][i]=dis[i][0]=x; if(x>Max){Max=x,id=i;} } int mx=0,r=0; rep(i,n) { if(i==id){continue;} if(dis[id][i]) { if(dis[id][i]>mx){mx=dis[id][i],r=i;} continue; } int v=getDistance(id,i);dis[id][i]=dis[i][id]=v; if(v>mx) { mx=v; r=i; } } int res=(1<<30); rep(i,n) { if(i==id||i==r){continue;} int fi=dis[i][id],se=dis[i][r]; if(!fi){fi=getDistance(i,id);dis[i][id]=dis[id][i]=fi;} if(!se){se=getDistance(i,r);dis[i][r]=dis[r][i]=fi;} if((fi+se-mx)&1){continue;} int inter=(fi+se-mx)/2; int L=fi-inter,R=se-inter; res=min(res,max(L,R)); } if(subtsk==4) { return -res; } return res; } return 0; }
#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...