제출 #1320384

#제출 시각아이디문제언어결과실행 시간메모리
1320384ThanhsRace (IOI11_race)C++20
컴파일 에러
0 ms0 KiB
#include "race.h" #include <bits/stdc++.h> using namespace std; #define name "TENBAI" #define fi first #define se second #define int long long #define endl '\n' #define setmin(x, y) x = min((x), (y)) #define setmax(x, y) x = max((x), (y)) #define sqr(x) ((x) * (x)) #define all(x) x.begin(), x.end() const int inf = 1e9; vector<pair<int, int>> g[NM]; int n, k, ans = inf, done[NM]; int dfs_sz(int u, int p) { sz[u] = 1; for (auto v : g[u]) if (v.fi != p && !done[v.fi]) sz[u] += dfs_sz(v.fi, u); return sz[u]; } int findcen(int u, int p, int SZ) { for (auto v : g[u]) if (v.fi != p && !done[v.fi] && 2 * sz[v.fi] >= SZ) return findcen(v.fi, u, SZ); return u; } void get(int u, int p, int w, int c) { if (mp.count(k - w)) setmin(ans, c + mp[k - w] - 1); for (auto v : g[u]) if (v.fi != p && !done[v.fi]) get(v.fi, u, w + v.se, c + 1); } void add(int u, int p, int w, int c) { setmin(mp[w], c); for (auto v : g[u]) if (v.fi != p && !done[v.fi]) get(v.fi, u, w + v.se, c + 1); } void cen(int u) { int c = findcen(u, 0, dfs_sz(u)); mp.clear(); mp[0] = 1; for (auto v : g[u]) if (!done[v.fi]) { get(v.fi, u, v.se, 2); add(v.fi, u, v.se, 2); } done[u] = 1; for (auto v : g[u]) if (!done[v.fi]) cen(v.fi); } int best_path(int N, int K, int H[][2], int L[]) { n = N; for (int i = 0; i < n - 1; i++) { g[H[i][0]].emplace_back(H[i][1], L[i]); g[H[i][1]].emplace_back(H[i][0], L[i]); } cen(1); return ans == inf ? -1 : ans; }

컴파일 시 표준 에러 (stderr) 메시지

race.cpp:17:26: error: 'NM' was not declared in this scope
   17 | vector<pair<int, int>> g[NM];
      |                          ^~
race.cpp:18:27: error: 'NM' was not declared in this scope
   18 | int n, k, ans = inf, done[NM];
      |                           ^~
race.cpp: In function 'long long int dfs_sz(long long int, long long int)':
race.cpp:22:5: error: 'sz' was not declared in this scope; did you mean 'se'?
   22 |     sz[u] = 1;
      |     ^~
      |     se
race.cpp:23:19: error: 'g' was not declared in this scope
   23 |     for (auto v : g[u])
      |                   ^
race.cpp:24:27: error: 'done' was not declared in this scope
   24 |         if (v.fi != p && !done[v.fi])
      |                           ^~~~
race.cpp: In function 'long long int findcen(long long int, long long int, long long int)':
race.cpp:31:19: error: 'g' was not declared in this scope
   31 |     for (auto v : g[u])
      |                   ^
race.cpp:32:27: error: 'done' was not declared in this scope
   32 |         if (v.fi != p && !done[v.fi] && 2 * sz[v.fi] >= SZ)
      |                           ^~~~
race.cpp:32:45: error: 'sz' was not declared in this scope; did you mean 'SZ'?
   32 |         if (v.fi != p && !done[v.fi] && 2 * sz[v.fi] >= SZ)
      |                                             ^~
      |                                             SZ
race.cpp: In function 'void get(long long int, long long int, long long int, long long int)':
race.cpp:39:9: error: 'mp' was not declared in this scope; did you mean 'p'?
   39 |     if (mp.count(k - w))
      |         ^~
      |         p
race.cpp:41:19: error: 'g' was not declared in this scope
   41 |     for (auto v : g[u])
      |                   ^
race.cpp:42:27: error: 'done' was not declared in this scope
   42 |         if (v.fi != p && !done[v.fi])
      |                           ^~~~
race.cpp: In function 'void add(long long int, long long int, long long int, long long int)':
race.cpp:48:12: error: 'mp' was not declared in this scope; did you mean 'p'?
   48 |     setmin(mp[w], c);
      |            ^~
race.cpp:10:22: note: in definition of macro 'setmin'
   10 | #define setmin(x, y) x = min((x), (y))
      |                      ^
race.cpp:49:19: error: 'g' was not declared in this scope
   49 |     for (auto v : g[u])
      |                   ^
race.cpp:50:27: error: 'done' was not declared in this scope
   50 |         if (v.fi != p && !done[v.fi])
      |                           ^~~~
race.cpp: In function 'void cen(long long int)':
race.cpp:56:33: error: too few arguments to function 'long long int dfs_sz(long long int, long long int)'
   56 |     int c = findcen(u, 0, dfs_sz(u));
      |                           ~~~~~~^~~
race.cpp:20:5: note: declared here
   20 | int dfs_sz(int u, int p)
      |     ^~~~~~
race.cpp:57:5: error: 'mp' was not declared in this scope
   57 |     mp.clear();
      |     ^~
race.cpp:59:19: error: 'g' was not declared in this scope
   59 |     for (auto v : g[u])
      |                   ^
race.cpp:60:14: error: 'done' was not declared in this scope
   60 |         if (!done[v.fi])
      |              ^~~~
race.cpp:65:5: error: 'done' was not declared in this scope
   65 |     done[u] = 1;
      |     ^~~~
race.cpp:66:19: error: 'g' was not declared in this scope
   66 |     for (auto v : g[u])
      |                   ^
race.cpp: In function 'long long int best_path(long long int, long long int, long long int (*)[2], long long int*)':
race.cpp:76:9: error: 'g' was not declared in this scope
   76 |         g[H[i][0]].emplace_back(H[i][1], L[i]);
      |         ^