Submission #374486

#TimeUsernameProblemLanguageResultExecution timeMemory
374486VEGAnnSvjetlo (COCI20_svjetlo)C++14
Compilation error
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; /// !!! const ll OO = 1e18; string s; int n, cnt[N]; ll f[N][2][2]; void dfs(int v, int p){ bool in = cnt[v]; int kol = 0; for (int u : g[v]){ if (u == p) continue; dfs(u, v); cnt[v] += cnt[u]; if (cnt[u] > 0) kol++; } if (cnt[v] == 0) continue; if (cnt[v] == 1 && in){ f[v][1][1] = 1; return; } if (kol == 1){ return; } if ((kol ^ was) % 2 == ){ } else { ll sm = 0; for (int u : g[v]){ if (u == p || cnt[u] == 0) continue; } } } 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++) f[v][t1][t2] = OO; dfs(0, -1); ll 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++) ans = min(ans, f[v][t1][t2]); } cout << ans; return 0; }

Compilation message (stderr)

svjetlo.cpp: In function 'void dfs(int, int)':
svjetlo.cpp:18:18: error: 'g' was not declared in this scope
   18 |     for (int u : g[v]){
      |                  ^
svjetlo.cpp:29:22: error: continue statement not within a loop
   29 |     if (cnt[v] == 0) continue;
      |                      ^~~~~~~~
svjetlo.cpp:41:16: error: 'was' was not declared in this scope
   41 |     if ((kol ^ was) % 2 == ){
      |                ^~~
svjetlo.cpp:41:28: error: expected primary-expression before ')' token
   41 |     if ((kol ^ was) % 2 == ){
      |                            ^
svjetlo.cpp:46:22: error: 'g' was not declared in this scope
   46 |         for (int u : g[v]){
      |                      ^
svjetlo.cpp:44:12: warning: unused variable 'sm' [-Wunused-variable]
   44 |         ll sm = 0;
      |            ^~
svjetlo.cpp: In function 'int main()':
svjetlo.cpp:75:9: error: 'g' was not declared in this scope
   75 |         g[x].PB(y);
      |         ^