Submission #847004

#TimeUsernameProblemLanguageResultExecution timeMemory
847004LeonaRagingCats or Dogs (JOI18_catdog)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> using namespace std; #define pb emplace_back const int maxn = 1e5 + 4; const int INF = 1e9; int n, val[maxn], dp[maxn][3]; vector<int> adj[maxn]; void dfs(int u, int p) { for (int j = 0; j < 3; j++) dp[u][j] = 0; for (int v : adj[u]) if (v != p) { dfs(v, u); dp[u][0] += min(dp[v][0], min(dp[v][1], dp[v][2]) + 1); dp[u][1] += min(min(dp[v][0], dp[v][1]), dp[v][2] + 1); dp[u][2] += min(min(dp[v][0], dp[v][2]), dp[v][1] + 1); } if (val[u] == 1) dp[u][0] = dp[u][2] = INF; if (val[u] == 2) dp[u][0] = dp[u][1] = INF; } int main() { ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cin >> n; for (int i = 1, u, v; i < n; i++) { cin >> u >> v; adj[u].pb(v); adj[v].pb(u); } int q; cin >> q; while (q--) { int t, u; cin >> t >> u; if (t == 1) val[u] = 1; if (t == 2) val[u] = 2; if (t == 3) val[u] = 0; dfs(1, 0); cout << min({dp[1][0], dp[1][1], dp[1][2]}) << '\n'; } }

Compilation message (stderr)

/usr/bin/ld: /tmp/ccChipmp.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccQKrV7o.o:catdog.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccChipmp.o: in function `main':
grader.cpp:(.text.startup+0x1f1): undefined reference to `initialize(int, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
/usr/bin/ld: grader.cpp:(.text.startup+0x229): undefined reference to `neighbor(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x26d): undefined reference to `dog(int)'
/usr/bin/ld: grader.cpp:(.text.startup+0x311): undefined reference to `cat(int)'
collect2: error: ld returned 1 exit status