Submission #387360

#TimeUsernameProblemLanguageResultExecution timeMemory
387360alireza_kavianiTowns (IOI15_towns)C++11
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "towns.h" using namespace std; #define SZ(x) int(x.size()) #define sep ' ' a const int MAXN = 110 + 10; const int MOD = 1e9 + 7; int cnt , dist[4][MAXN] , val[MAXN][MAXN]; int get(int v , int u){ if(val[v][u] != -1) return val[v][u]; val[v][u] = val[u][v] = getDistance(v , u); cnt--; assert(cnt >= 0); return val[v][u]; } int ask(int ind , int v , int n){ int mx = 0; for(int i = 0 ; i < n ; i++){ dist[ind][i] = get(v , i); if(dist[ind][i] > dist[ind][mx]) mx = i; } return mx; } int hubDistance(int N, int sub) { memset(val , -1 , sizeof(val)); cnt = N * (N - 1) / 2; int v = ask(0 , 0 , N); int u = ask(1 , v , N); ask(2 , u , N); int mn = MOD; for(int i = 0 ; i < N ; i++){ mn = min(mn , abs(dist[1][i] - dist[2][i])); // cout << i << sep << dist[1][i] << sep << dist[2][i] << endl; } // cout << v << sep << u << endl; int xl = 0 , xr = 0 , yl = 0 , yr = 0; vector<int> v1 , v2; for(int i = 0 ; i < N ; i++){ int val = dist[1][i] - dist[2][i]; dist[3][i] = (dist[1][i] + dist[2][i] - dist[1][u]) / 2; if(val < -mn) xl++; if(val == -mn) yl++ , v1.push_back(i); if(val == mn) yr++ , v2.push_back(i); if(val > mn) xr++; } int R = (dist[1][u] + mn) / 2; if(xl <= N / 2 && yl <= N / 2 && xr + yr <= N / 2) return R; if(xr <= N / 2 && yr <= N / 2 && xl + yl <= N / 2) return R; if(sub == 1 || sub == 2 || sub == 4) return -R; yl = yr = 0; for(int i = 0 ; i < SZ(v1) ; i++){ int cur = 1; for(int j = 0 ; j < i ; j++){ if(dist[3][v1[i]] + dist[3][v1[j]] > get(v1[i] , v1[j])) cur++; } yl = max(yl , cur); } for(int i = 0 ; i < SZ(v2) ; i++){ int cur = 1; for(int j = 0 ; j < i ; j++){ if(dist[3][v2[i]] + dist[3][v2[j]] > get(v2[i] , v2[j])) cur++; } yr = max(yr , cur); } //cout << xl << sep << yl << sep << xr << sep << yr << endl; if(xl <= N / 2 && yl <= N / 2 && xr + SZ(v2) <= N / 2) return R; if(xr <= N / 2 && yr <= N / 2 && xl + SZ(v1) <= N / 2) return R; return -R; }

Compilation message (stderr)

towns.cpp:7:1: error: 'a' does not name a type
    7 | a
      | ^
towns.cpp:11:19: error: 'MAXN' was not declared in this scope
   11 | int cnt , dist[4][MAXN] , val[MAXN][MAXN];
      |                   ^~~~
towns.cpp:11:31: error: 'MAXN' was not declared in this scope
   11 | int cnt , dist[4][MAXN] , val[MAXN][MAXN];
      |                               ^~~~
towns.cpp:11:37: error: 'MAXN' was not declared in this scope
   11 | int cnt , dist[4][MAXN] , val[MAXN][MAXN];
      |                                     ^~~~
towns.cpp: In function 'int get(int, int)':
towns.cpp:14:5: error: 'val' was not declared in this scope
   14 |  if(val[v][u] != -1) return val[v][u];
      |     ^~~
towns.cpp:15:2: error: 'val' was not declared in this scope
   15 |  val[v][u] = val[u][v] = getDistance(v , u); cnt--;
      |  ^~~
towns.cpp: In function 'int ask(int, int, int)':
towns.cpp:23:3: error: 'dist' was not declared in this scope
   23 |   dist[ind][i] = get(v , i);
      |   ^~~~
towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:30:9: error: 'val' was not declared in this scope
   30 |  memset(val , -1 , sizeof(val)); cnt = N * (N - 1) / 2;
      |         ^~~
towns.cpp:36:21: error: 'dist' was not declared in this scope
   36 |   mn = min(mn , abs(dist[1][i] - dist[2][i]));
      |                     ^~~~
towns.cpp:43:7: warning: declaration of 'val' shadows a previous local [-Wshadow]
   43 |   int val = dist[1][i] - dist[2][i];
      |       ^~~
towns.cpp:30:9: note: shadowed declaration is here
   30 |  memset(val , -1 , sizeof(val)); cnt = N * (N - 1) / 2;
      |         ^~~
towns.cpp:43:13: error: 'dist' was not declared in this scope
   43 |   int val = dist[1][i] - dist[2][i];
      |             ^~~~
towns.cpp:50:11: error: 'dist' was not declared in this scope
   50 |  int R = (dist[1][u] + mn) / 2;
      |           ^~~~