Submission #427133

# Submission time Handle Problem Language Result Execution time Memory
427133 2021-06-14T12:38:40 Z ollel Towns (IOI15_towns) C++17
0 / 100
18 ms 976 KB
#include <bits/stdc++.h>
#include <iostream>
#include "towns.h"
using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define pb push_back
#define lso(x) x&(-x)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

int n, s;

int hubDistance(int N, int S) {
  n = N; s = S;

  vvi d(n, vi(n));
  rep(i,0,n) d[i][i] = 0;
  rep(i, 0, n) rep(j, i + 1, n) {
    d[i][j] = d[j][j] = getDistance(i, j);
  }

  int a, b, m = 0;
  rep(i,0,n) rep(j,i+1,n) {
    if (d[i][j] > m) {a = i; b = j; m = d[i][j];}
  }

  int ab = d[a][b];

  rep(k, 1, ab) {
    int s = ab - k;
    rep(c,0,n) {
      if (c == a || c == b) continue;
      if (d[a][c] - k == d[b][c] - s) return max(s, k);
    }
  }

}

Compilation message

towns.cpp: In function 'int hubDistance(int, int)':
towns.cpp:33:9: warning: declaration of 's' shadows a global declaration [-Wshadow]
   33 |     int s = ab - k;
      |         ^
towns.cpp:14:8: note: shadowed declaration is here
   14 | int n, s;
      |        ^
towns.cpp:19:17: warning: control reaches end of non-void function [-Wreturn-type]
   19 |   vvi d(n, vi(n));
      |                 ^
towns.cpp:35:23: warning: 'b' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |       if (c == a || c == b) continue;
      |                     ~~^~~~
towns.cpp:35:13: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |       if (c == a || c == b) continue;
      |           ~~^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 18 ms 976 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 14 ms 844 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 332 KB Output isn't correct
2 Halted 0 ms 0 KB -