Submission #387445

#TimeUsernameProblemLanguageResultExecution timeMemory
387445mehrdad_sohrabiTowns (IOI15_towns)C++14
25 / 100
26 ms748 KiB
/// Black lives matter #include <bits/stdc++.h> #include "towns.h" /// 500 485 462 A4 using namespace std; typedef long long int ll; typedef complex<double> point; typedef long double ld; #define pb push_back #define pii pair < ll , ll > #define F first #define S second //#define endl '\n' #define int long long #define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0) #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math") #define kill(x) return cout<<x<<'\n', 0; const int N=200; /* ll disin[N][N]; int getDistance(ll u,ll v){ return disin[u][v]; } */ ll dis[N][N]; int32_t hubDistance(int32_t n, int32_t sub) { ll mx0=0,id0=0,mx1=0,id1=0; memset(dis,-1,sizeof dis); for (int i=1;i<n;i++){ if (dis[0][i]==-1) dis[0][i]=getDistance(0,i),dis[i][0]=dis[0][i]; if (dis[0][i]>mx0){ mx0=dis[0][i]; id0=i; } } for (int i=0;i<n;i++){ if (dis[id0][i]==-1) dis[id0][i]=getDistance(id0,i),dis[i][id0]=dis[id0][i]; if (dis[id0][i]>mx1){ mx1=dis[id0][i]; id1=i; } } ll ans=dis[id0][id1],mn=1e9; for (int i=0;i<n;i++){ if (i==id0 || i==id1) continue; dis[id1][i]=getDistance(id1,i); dis[i][id1]=dis[id1][i]; ll z=abs(dis[id0][i]-dis[id1][i]); mn=min(mn,z); } return (ans+mn)/2; } /* int32_t main(){ ll x,y; cin >> x >> y; ll n; cin >> n; for (int i=0;i<n;i++){ for (int j=0;j<n;j++) cin >> disin[i][j]; } cout << hubDistance(n,y); } */ /* 1 1 11 0 17 18 20 17 12 20 16 23 20 11 17 0 23 25 22 17 25 21 28 25 16 18 23 0 12 21 16 24 20 27 24 17 20 25 12 0 23 18 26 22 29 26 19 17 22 21 23 0 9 21 17 26 23 16 12 17 16 18 9 0 16 12 21 18 11 20 25 24 26 21 16 0 10 29 26 19 16 21 20 22 17 12 10 0 25 22 15 23 28 27 29 26 21 29 25 0 21 22 20 25 24 26 23 18 26 22 21 0 19 11 16 17 19 16 11 19 15 22 19 0 */

Compilation message (stderr)

towns.cpp: In function 'int32_t hubDistance(int32_t, int32_t)':
towns.cpp:30:52: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   30 |         if (dis[0][i]==-1) dis[0][i]=getDistance(0,i),dis[i][0]=dis[0][i];
      |                                                    ^
towns.cpp:37:54: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   37 |         if (dis[id0][i]==-1) dis[id0][i]=getDistance(id0,i),dis[i][id0]=dis[id0][i];
      |                                                      ^~~
towns.cpp:37:58: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   37 |         if (dis[id0][i]==-1) dis[id0][i]=getDistance(id0,i),dis[i][id0]=dis[id0][i];
      |                                                          ^
towns.cpp:46:33: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   46 |         dis[id1][i]=getDistance(id1,i);
      |                                 ^~~
towns.cpp:46:37: warning: conversion from 'long long int' to 'int' may change value [-Wconversion]
   46 |         dis[id1][i]=getDistance(id1,i);
      |                                     ^
towns.cpp:51:17: warning: conversion from 'll' {aka 'long long int'} to 'int32_t' {aka 'int'} may change value [-Wconversion]
   51 |  return (ans+mn)/2;
      |         ~~~~~~~~^~
towns.cpp:26:40: warning: unused parameter 'sub' [-Wunused-parameter]
   26 | int32_t hubDistance(int32_t n, int32_t 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...