Submission #1173175

#TimeUsernameProblemLanguageResultExecution timeMemory
1173175nguyenkhangninh99Easter Eggs (info1cup17_eastereggs)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; int tin[maxn], f[maxn], timeDfs; void dfs(int u, int pre){ tin[u] = ++timeDfs; f[timeDfs] = u; for(int v: g[u]){ if(v == pre) dfs(v, u); } } bool ok(int mid){ vector<int> v; for(int i = 1; i <= mid; i++) v.push_back(f[i]); return query(v); } int findEgg(int N, vector <pair<int, int>> bridges){ int n = N; for(int i = 0; i < n - 1; i++){ int u = bridge[i].first, v = bridge[i].second; g[u].push_back(v); g[v].push_back(u); } dfs(1, 0); int l = 1, r = n, ans = -1; while(l <= r){ int mid = (l + r) / 2; if(ok(mid)){ ans = mid; r = mid - 1; } else l = mid + 1; } cout << f[ans]; }

Compilation message (stderr)

eastereggs.cpp:7:9: error: 'maxn' was not declared in this scope
    7 | int tin[maxn], f[maxn], timeDfs;
      |         ^~~~
eastereggs.cpp:7:18: error: 'maxn' was not declared in this scope
    7 | int tin[maxn], f[maxn], timeDfs;
      |                  ^~~~
eastereggs.cpp: In function 'void dfs(int, int)':
eastereggs.cpp:10:5: error: 'tin' was not declared in this scope; did you mean 'tan'?
   10 |     tin[u] = ++timeDfs;
      |     ^~~
      |     tan
eastereggs.cpp:11:5: error: 'f' was not declared in this scope
   11 |     f[timeDfs] = u;
      |     ^
eastereggs.cpp:13:16: error: 'g' was not declared in this scope
   13 |     for(int v: g[u]){
      |                ^
eastereggs.cpp: In function 'bool ok(int)':
eastereggs.cpp:20:47: error: 'f' was not declared in this scope
   20 |     for(int i = 1; i <= mid; i++) v.push_back(f[i]);
      |                                               ^
eastereggs.cpp:21:12: error: 'query' was not declared in this scope
   21 |     return query(v);
      |            ^~~~~
eastereggs.cpp: In function 'int findEgg(int, std::vector<std::pair<int, int> >)':
eastereggs.cpp:28:17: error: 'bridge' was not declared in this scope; did you mean 'bridges'?
   28 |         int u = bridge[i].first, v = bridge[i].second;
      |                 ^~~~~~
      |                 bridges
eastereggs.cpp:29:9: error: 'g' was not declared in this scope
   29 |         g[u].push_back(v);
      |         ^
eastereggs.cpp:29:24: error: 'v' was not declared in this scope
   29 |         g[u].push_back(v);
      |                        ^
eastereggs.cpp:47:13: error: 'f' was not declared in this scope
   47 |     cout << f[ans];
      |             ^
eastereggs.cpp:48:1: warning: no return statement in function returning non-void [-Wreturn-type]
   48 | }
      | ^