Submission #592211

#TimeUsernameProblemLanguageResultExecution timeMemory
592211DeepessonTowns (IOI15_towns)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #define MAX 115 int getDistance(int i, int j); int hubDistance(int N, int sub); typedef std::pair<int,int> pii; int dist[MAX][2]; pii MaisDistante(int N,int x,int p){ int best=-1,alvo=0; for(int i=0;i!=N;++i){ if(i==x)continue; int d = getDistance(i,x); if(d>best){ best=d; alvo=i; } dist[i][p]=d; } return {best,alvo}; } ///Queries usadas: 3N-3 int hubDistance(int N, int sub) { pii alpha = MaisDistante(N,0,1); pii beta = MaisDistante(N,alpha.second,0); MaisDistante(N,beta.second,1); int d = beta.first; int ans=1e9; int eixo; int grupos[2]={1,1}; std::vector<int> fora; for(int i=0;i!=N;++i){ if(i==alpha.second||i==beta.second)continue; int a = dist[i][0]; int b = dist[i][1]; int soma = a+b; int subt = soma-d; int base = subt/2; int custo = std::max(a,b)-base; if(custo<ans){///Fora da sub de A ou B eixo=i; ans=custo; } } if(sub<=2) return ans; for(int i=0;i!=N;++i){ if(i==alpha.second||i==beta.second)continue; int a = dist[i][0]; int b = dist[i][1]; int soma = a+b; int subt = soma-d; int base = subt/2; int custo = std::max(a,b)-base; if(custo==ans){///Fora da sub de A ou B fora.push_back(i); }else {///Na subarvore de A ou B if(a>b)grupos[0]++;else grupos[1]++; } } int lim=N/2; if(grupos[0]>lim||grupos[1]>lim)return -R; ///Para a sub 3 int sum = grupos[0]+grupos[1]; if(sum>lim)return -R; return R; }

Compilation message (stderr)

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:60:42: error: 'R' was not declared in this scope
   60 |  if(grupos[0]>lim||grupos[1]>lim)return -R;
      |                                          ^
towns.cpp:63:21: error: 'R' was not declared in this scope
   63 |  if(sum>lim)return -R;
      |                     ^
towns.cpp:64:9: error: 'R' was not declared in this scope
   64 |  return R;
      |         ^