제출 #1090886

#제출 시각아이디문제언어결과실행 시간메모리
1090886owoovo도시들 (IOI15_towns)C++17
0 / 100
10 ms600 KiB
#include "towns.h" #include<bits/stdc++.h> #define ll long long #define F first #define S second using namespace std; const ll maxn=1e18; ll to0[120],tor1[120],tor2[120],gf[120][120]; ll r1,r2; int getd(int a,int b){ return gf[a][b]; } int hubDistance(int N, int sub) { for(int i=0;i<N;i++){ for(int j=i+1;j<N;j++){ gf[i][j]=getDistance(i,j); gf[j][i]=gf[i][j]; } } for(int i=1;i<N;i++)to0[i]=getd(0,i); ll maxn=0,pos=0; for(int i=0;i<N;i++){ if(to0[i]>maxn){ maxn=to0[i]; pos=i; } } r1=pos; for(int i=0;i<N;i++)tor1[i]=getd(r1,i); maxn=0,pos=0; for(int i=0;i<N;i++){ if(tor1[i]>maxn){ maxn=tor1[i]; pos=i; } } r2=pos; vector<pair<ll,ll>> vc; for(int i=0;i<N;i++){ //cout<<i<<" "<<tor1[r2]<<" "<<tor1[i]<<" "<<tor2[i]<<"\n"; ll dis=(to0[r2]+tor1[i]-to0[i])/2; vc.push_back({dis,tor1[i]-dis}); } ll ans=maxn; for(int i=0;i<N;i++){ ans=min(ans,max(vc[i].F,tor1[r2]-vc[i].F)); } vector<ll> want; for(int i=0;i<N;i++){ if(ans==max(vc[i].F,tor1[r2]-vc[i].F)){ want.push_back(vc[i].F); } } int ok=0; for(auto dis:want){ int s=0,m=0,l=0; vector<int> now; for(int i=0;i<N;i++){ if(vc[i].F<dis)s++; else if(vc[i].F==dis)now.push_back(i); else l++; } if(s>N/2||l>N/2)continue; int vis[120]={0},OK=1; for(int i=0,x=now[i];i<now.size();i++,x=now[i]){ if(vis[x])continue; vis[x]=1; int bk=1; for(int j=i,y=now[j];j<now.size();j++,y=now[j]){ if(vis[y])continue; int dd=getd(x,y); if(dd<vc[x].S+vc[y].S){ vis[y]=1; bk++; } } if(bk>N/2)OK=0; } ok|=OK; } return ok==1?ans:-ans; }

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

towns.cpp: In function 'int getd(int, int)':
towns.cpp:11:16: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   11 |  return gf[a][b];
      |         ~~~~~~~^
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:21:5: warning: declaration of 'maxn' shadows a global declaration [-Wshadow]
   21 |  ll maxn=0,pos=0;
      |     ^~~~
towns.cpp:7:10: note: shadowed declaration is here
    7 | const ll maxn=1e18;
      |          ^~~~
towns.cpp:29:35: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   29 |  for(int i=0;i<N;i++)tor1[i]=getd(r1,i);
      |                                   ^~
towns.cpp:65:25: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   65 |   for(int i=0,x=now[i];i<now.size();i++,x=now[i]){
      |                        ~^~~~~~~~~~~
towns.cpp:69:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |    for(int j=i,y=now[j];j<now.size();j++,y=now[j]){
      |                         ~^~~~~~~~~~~
towns.cpp:56:11: warning: unused variable 'm' [-Wunused-variable]
   56 |   int s=0,m=0,l=0;
      |           ^
towns.cpp:81:14: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   81 |  return ok==1?ans:-ans;
      |         ~~~~~^~~~~~~~~
towns.cpp:13:28: warning: unused parameter 'sub' [-Wunused-parameter]
   13 | 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...