제출 #374475

#제출 시각아이디문제언어결과실행 시간메모리
374475VEGAnnSvjetlo (COCI20_svjetlo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; typedef long double ld; typedef long long ll; const ld E = 1e-9; const int N = 500100; const int oo = 1e9; /// !!! string s; int n, f[N][2][2][2], cnt[N]; void dfs(int v, int p){ bool in = cnt[v]; for (int u : g[v]){ if (u == p) continue; dfs(u, v); cnt[v] += cnt[u]; } if (cnt[v] == 0) continue; if (cnt[v] == 1 && in){ f[v][1][1][0] = 0; f[v][1][1][1] = 1; return; } } int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> n >> s; int need = 0; for (int i = 0; i < n; i++) { cnt[i] = bool(s[i] == '0'); need += cnt[i]; } assert(need > 0); for (int i = 1; i < n; i++){ int x, y; cin >> x >> y; x--; y--; g[x].PB(y); g[y].PB(x); } for (int v = 0; v < n; v++) for (int t1 = 0; t1 < 2; t1++) for (int t2 = 0; t2 < 2; t2++) for (int t3 = 0; t3 < 2; t3++) f[v][t1][t2][t3] = oo; dfs(0, -1); int ans = oo; for (int v = 0; v < n; v++){ if (cnt[v] < need) continue; for (int t1 = 0; t1 < 2; t1++) for (int t2 = 0; t2 < 2; t2++) for (int t3 = 0; t3 < 2; t3++) ans = min(ans, f[v][t1][t2][t3]); } cout << ans; return 0; }

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

svjetlo.cpp: In function 'void dfs(int, int)':
svjetlo.cpp:14:18: error: 'g' was not declared in this scope
   14 |     for (int u : g[v]){
      |                  ^
svjetlo.cpp:22:22: error: continue statement not within a loop
   22 |     if (cnt[v] == 0) continue;
      |                      ^~~~~~~~
svjetlo.cpp: In function 'int main()':
svjetlo.cpp:54:9: error: 'g' was not declared in this scope
   54 |         g[x].PB(y);
      |         ^