Submission #1080196

#TimeUsernameProblemLanguageResultExecution timeMemory
1080196TrumlingTowns (IOI15_towns)C++14
0 / 100
1 ms348 KiB
#include "towns.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second #define pb push_back #define all(x) x.begin(),x.end() #define INF 9999999999999 typedef long long ll; int hubDistance(int N, int sub) { ll n=N; vector<vector<ll>>g(N,vector<ll>(N)); ll maxi=-1; pair<ll,ll>curr; for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) { ll R=getDistance(i,j); g[i][j]=R; g[j][i]=R; if(maxi<R) { maxi=g[i][j]; curr={i,j}; } } ll ans=INF; for(int i=0;i<n;i++) if(i!=curr.F && i!=curr.S) { ll f=(g[i][curr.F] + g[i][curr.S] - maxi)/2; ans=min(ans,max(g[i][curr.F]-f,g[i][curr.S]-f)); } int tf=1; vector<bool>vis; for(int i=0;i<n;i++) if(i!=curr.F && i!=curr.S && !vis[i]) { vis[i]=1; ll count=0; for(int j=0;j<n;j++) if(j!=i) { ll f1=(g[i][curr.F] + g[i][curr.S] - maxi)/2; ll f2=(g[j][curr.F] + g[j][curr.S] - maxi)/2; if(g[i][j]<max(f1,f2)) { vis[j]=1; count++; } } if(count>n/2) tf=-1; } return ans*tf; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:33:6: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   33 |      for(int i=0;i<n;i++)
      |      ^~~
towns.cpp:39:3: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   39 |   int tf=1;
      |   ^~~
towns.cpp:62:16: warning: conversion from 'll' {aka 'long long int'} to 'int' may change value [-Wconversion]
   62 |      return ans*tf;
      |             ~~~^~~
towns.cpp:12:32: warning: unused parameter 'sub' [-Wunused-parameter]
   12 |     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...