Submission #102421

#TimeUsernameProblemLanguageResultExecution timeMemory
102421CaroLindaTowns (IOI15_towns)C++14
35 / 100
27 ms504 KiB
#include "towns.h" #include <bits/stdc++.h> #define lp(i,a,b) for(int i = a ; i < b ; i++) #define ff first #define ss second #define pii pair<int,int> #define INF 1000010*110 const int MAXN = 120 ; using namespace std; int m[MAXN][MAXN] ; int d[MAXN] ; void ini() { lp(i,0,MAXN) lp(j, 0 , MAXN) m[i][j] = -1 ; } int query(int A ,int N) { pii p = pii(-1,-1) ; lp(i,0,N) { if( i == A ) continue ; m[A][i] = getDistance(A,i) ; if(m[A][i]>p.ss) p = pii( i , m[A][i] ) ; } return p.ff ; } int hubDistance( int N , int sub ) { ini(); int B = query(0 , N) ; int C = query(B , N) ; query(C , N) ; int R = INF , esq = 0 , dir = 0 , meio = 0, antigo, cara; lp(i,0,N) if(i!=C and i!=B) { int b = (m[B][i]+m[C][i] - m[B][C])/2 ; d[i] = b ; antigo=R; R = min( R , max( m[B][i] , m[C][i] ) - b ) ; if(R<antigo) cara = m[B][i]>m[C][i] ? B : C ; } if(sub < 3) return R ; d[B] = d[C] = 0 ; lp(i,0,N) { int x = m[cara][i] - d[i] ; if(x<R) esq++ ; else if(x>R) dir++ ; else meio++ ; } int k = N/2 ; if(meio>k or esq>k or dir>k) return -R ; return R ; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:46:55: warning: 'cara' may be used uninitialized in this function [-Wmaybe-uninitialized]
   int R = INF , esq = 0 , dir = 0 , meio = 0, antigo, cara;
                                                       ^~~~
#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...