제출 #1130215

#제출 시각아이디문제언어결과실행 시간메모리
1130215fzyzzz_zJOI tour (JOI24_joitour)C++20
컴파일 에러
0 ms0 KiB
// #include "joitour.cpp" #include <bits/stdc++.h> using namespace std; using ll = long long; ll cnt[3]{0, 0, 0}, bad = 0; int n; int col[200005]; struct HLD { int n; std::vector<int> siz, top, parent, tin, tout, seq; std::vector<std::vector<int>> adj; int cur; HLD() {} HLD(int n) { init(n); } void init(int n) { this->n = n; siz.resize(n); top.resize(n); parent.resize(n); tin.resize(n); tout.resize(n); seq.resize(n); cur = 0; adj.assign(n, {}); } void addEdge(int u, int v) { adj[u].push_back(v); adj[v].push_back(u); } void work(int root = 0) { top[root] = root; parent[root] = -1; dfs1(root); dfs2(root); } void dfs1(int u) { if (parent[u] != -1) { adj[u].erase(std::find(adj[u].begin(), adj[u].end(), parent[u])); } siz[u] = 1; for (auto &v : adj[u]) { parent[v] = u; dfs1(v); siz[u] += siz[v]; if (siz[v] > siz[adj[u][0]]) { std::swap(v, adj[u][0]); } } } void dfs2(int u) { tin[u] = cur++; seq[tin[u]] = u; for (auto v : adj[u]) { top[v] = v == adj[u][0] ? top[u] : v; dfs2(v); } tout[u] = cur; } }; HLD h; void add0(int x) { // segtree // point update // range query for (auto s: h.adj[x]) { } // for each subtree // bad += s.cnt[1] * s.cnt[2] } void rem0(int x) { // add and activate // st support range add (only to those active) // point activate/deactivate // for each subtree // bad -= s.cnt[1] * s.cnt[2] } void addc(int x, int y) { // bad += path from x to 0 cnt pointing of y ^ 1 // bad += all other excluding path pointing to parent of y ^ 1 } void remc(int x, int y) { } void init(int N, std::vector<int> F, std::vector<int> U, std::vector<int> V, int Q) { n = N; for (int i = 0; i < n; ++i) { col[i] = F[i]; cnt[F[i]]++; } h.init(n); for (int i = 0; i < n - 1; ++i) { h.addEdge(U[i], V[i]); } h.work(); for (int i = 0; i < n; ++i) { if (col[i]) addc(i, col[i]); else add0(i); } } void change(int x, int y) { int cur = col[x]; if (cur == 0) rem0(x); else remc(x, cur); if (y == 0) add0(x); else addc(x, y); } long long num_tours() { ll res = cnt[0] * cnt[1] * cnt[2]; res -= bad; cout << res << '\n'; return res; } int32_t main() { init(3, {0, 1, 2}, {0, 1}, {1, 2}, 0); num_tours(); }

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

/usr/bin/ld: /tmp/ccDRYz5Z.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccgTbvZr.o:joitour.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status