Submission #1090619

#TimeUsernameProblemLanguageResultExecution timeMemory
1090619owoovo도시들 (IOI15_towns)C++17
25 / 100
15 ms1112 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]; ll r1,r2; int hubDistance(int N, int sub) { for(int i=1;i<N;i++)to0[i]=getDistance(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]=getDistance(r1,i); maxn=0,pos=0; for(int i=0;i<N;i++){ if(tor1[i]>maxn){ maxn=tor1[i]; pos=i; } } r2=pos; for(int i=0;i<N;i++)tor2[i]=getDistance(r2,i); vector<pair<ll,ll>> vc; for(int i=0;i<N;i++){ //cout<<i<<" "<<tor1[r2]<<" "<<tor1[i]<<" "<<tor2[i]<<"\n"; ll dis=(tor1[r2]+tor1[i]-tor2[i])/2; vc.push_back({dis,tor1[i]-dis}); } ll ans=maxn; for(int i=0;i<N;i++){ //cout<<i<<" "<<vc[i].F<<" "<<tor1[r2]-vc[i].F<<"\n"; ans=min(ans,max(vc[i].F,tor1[r2]-vc[i].F)); } //cout<<r1<<" "<<r2<<"\n"; return ans; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:12:5: warning: declaration of 'maxn' shadows a global declaration [-Wshadow]
   12 |  ll maxn=0,pos=0;
      |     ^~~~
towns.cpp:7:10: note: shadowed declaration is here
    7 | const ll maxn=1e18;
      |          ^~~~
towns.cpp:20:42: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   20 |  for(int i=0;i<N;i++)tor1[i]=getDistance(r1,i);
      |                                          ^~
towns.cpp:29:42: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   29 |  for(int i=0;i<N;i++)tor2[i]=getDistance(r2,i);
      |                                          ^~
towns.cpp:42:9: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   42 |  return ans;
      |         ^~~
towns.cpp:10:28: warning: unused parameter 'sub' [-Wunused-parameter]
   10 | 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...