제출 #784682

#제출 시각아이디문제언어결과실행 시간메모리
784682aVe경주 (Race) (IOI11_race)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "race.h" using namespace std; #define pb push_back #define mp make_pair typedef long long ll; typedef pair<long long, long long> pll; typedef pair<int,int> pii; typedef vector<long long> vl; typedef vector<int> vi; const int N = 1e6 + 5; vector<pii> G[N]; int ans = 1e9, arr[N], tmp[N], sz[N], l[N], r[N], k, mx; bool vis[N]; int get_sz(int node, int p = -1){ sz[node] = 1; for(auto next : G[node]){ if(!next.first != p && !vis[next.first]){ sz[node] += get_sz(next.first, node); } } return sz[node]; } int get_centroid(int node, int size, int p = -1){ for(auto next : G[node]){ if(next.first == p || vis[next.first]) continue; if(sz[next.first] >= size) return get_centroid(next.first, size, node); } return node; } void cnt(int node, int p, int yes, int sum, int level){ if(sum > k) return; if(sum == k) ans = min(ans, level); if(yes == 1) tmp[sum] = min(tmp[sum], level); else if(yes) tmp[sum] = 1e9; else ans = min(ans, level + tmp[k-sum]); for(auto next : G[node]){ if(next.first != p && !vis[next.first]) cnt(next.first, node, yes, sum + next.second, level+1); } } void decompose(int node = 0){ get_sz(node); int c = get_centroid(node, sz[node]/2); vis[c] = 1; mx = 0; for(auto next : G[node]){ if(!vis[next.first]) cnt(next.first, c, 0, next.second, 1), cnt(next.first, c, 1, next.second, 1); } for(auto next : G[node]){ if(!vis[next.first]) cnt(next.first, c, 2, next.second, 1); } for(auto next : G[node]){ if(!vis[next.first]) decompose(next.first); } } int best_path(int N, int K, int H[][2], int L[]){ fill(tmp, tmp+1000000 + 5, 1e9); n= N, k = K; for(int i = 0; i < N-1; i++){ G[H[i][1]].pb({H[i][0], L[i]}); G[H[i][0]].pb({H[i][1], L[i]}); } decompose(); return (ans == 1e9) ? -1 : ans; }

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

race.cpp: In function 'int get_sz(int, int)':
race.cpp:18:18: warning: logical not is only applied to the left hand side of comparison [-Wlogical-not-parentheses]
   18 |   if(!next.first != p && !vis[next.first]){
      |                  ^~
race.cpp:18:6: note: add parentheses around left hand side expression to silence this warning
   18 |   if(!next.first != p && !vis[next.first]){
      |      ^~~~~~~~~~~
      |      (          )
race.cpp: In function 'int best_path(int, int, int (*)[2], int*)':
race.cpp:61:2: error: 'n' was not declared in this scope
   61 |  n= N, k = K;
      |  ^