Submission #456204

#TimeUsernameProblemLanguageResultExecution timeMemory
456204sean617Race (IOI11_race)C++98
Compilation error
0 ms0 KiB
#include <iostream> #include <cstdio> #include <cstring> #include <vector> #include <queue> #define N 200005 #define A 1000005 #include "race.h" using namespace std; int n, k, mn, M = 1e9, s[A], sz[N]; bool v2[N]; vector<int> a[N], b[N]; queue<int> qu; int gs(int p, int q) { int i, t; sz[p] = 1; for (i = 0; i < a[p].size(); i++) { t = a[p][i]; if (t == q || v2[t]) continue; sz[p] += gs(t, p); } return sz[p]; } int gc(int p, int q, int nn) { int i, t; for (i = 0; i < a[p].size(); i++) { t = a[p][i]; if (t != q && !v2[t] && sz[t] *2 > nn) return gc(t, p, nn); } return p; } void g(int p, int q, int w, int cnt) { int i, t; if (w > k) return; mn = min(mn, cnt + s[k - w]); for (i = 0; i < a[p].size(); i++) { t = a[p][i]; if (t == q || v2[t]) continue; g(t, p, w + b[p][i], cnt + 1); } } void up(int p, int q, int w, int cnt) { int i, t; if (w > k) return; if (s[w] > cnt) { s[w] = cnt; qu.push(w); } for (i = 0; i < a[p].size(); i++) { t = a[p][i]; if (t == q || v2[t]) continue; up(t, p, w + b[p][i], cnt + 1); } } void f(int p) { int i, t, cen; gs(p, -1); cen = gc(p, -1, sz[p]); v2[cen] = 1; while (!qu.empty()) { t = qu.front(); qu.pop(); s[t] = M; } s[0] = 0; for (i = 0; i < a[cen].size(); i++) { t = a[cen][i]; if (v2[t]) continue; g(t, -1, b[cen][i], 1); up(t, -1, b[cen][i], 1); } for (i = 0; i < a[cen].size(); i++) { t = a[cen][i]; if (v2[t]) continue; f(t); } } int best_path(int NN, int KK, int H[][2], int L[]) { int i, t1, t2, t3; n = NN; k = KK; for (i = 0; i < n - 1; i++) { t1 = H[i][0]; t2 = H[i][1]; t3 = L[i]; a[t1].push_back(t2); b[t1].push_back(t3); a[t2].push_back(t1); b[t2].push_back(t3); } mn = M; for (i = 0; i <= k; i++) s[i] = M; f(0); if (mn == M) mn = -1; return mn; }

Compilation message (stderr)

race.cpp:6:11: error: expected ',' or '...' before numeric constant
    6 | #define N 200005
      |           ^~~~~~
race.h:1:19: note: in expansion of macro 'N'
    1 | int best_path(int N, int K, int H[][2], int L[]);
      |                   ^
race.cpp: In function 'int gs(int, int)':
race.cpp:21:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   21 |  for (i = 0; i < a[p].size(); i++) {
      |              ~~^~~~~~~~~~~~~
race.cpp: In function 'int gc(int, int, int)':
race.cpp:31:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   31 |  for (i = 0; i < a[p].size(); i++) {
      |              ~~^~~~~~~~~~~~~
race.cpp: In function 'void g(int, int, int, int)':
race.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |  for (i = 0; i < a[p].size(); i++) {
      |              ~~^~~~~~~~~~~~~
race.cpp: In function 'void up(int, int, int, int)':
race.cpp:56:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   56 |  for (i = 0; i < a[p].size(); i++) {
      |              ~~^~~~~~~~~~~~~
race.cpp: In function 'void f(int)':
race.cpp:73:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |  for (i = 0; i < a[cen].size(); i++) {
      |              ~~^~~~~~~~~~~~~~~
race.cpp:79:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |  for (i = 0; i < a[cen].size(); i++) {
      |              ~~^~~~~~~~~~~~~~~