제출 #1159625

#제출 시각아이디문제언어결과실행 시간메모리
1159625WendidiaskIsland Hopping (JOI24_island)C++20
컴파일 에러
0 ms0 KiB
/* :---:--:--::::::--:-:----: ::-:::. ::-::: .* -===.. :--- .-+*##=-------====-: :--: :+##=.* -= :=+- .-=: .+++-. :- -=. .=+- .--. .++=- + -= :*- :-. +*+- :- -=. -*: :=: #*: * -=. +- .= =:%+ -: -=. +- -- -%: * -=. *: +. :%-.. =. -=. # -: :=# .. + -=. == -= ---+ . = -=. .# .+ -: == . = :------::------:.-=. % .= :- == .=. ---:. :--#+. .% :- = .* .+.. :=- :++ -+ =: + #. + -=: :*%-*: * := :# :=:= . :-----: =+-+ .+ * -* *=- . .- :::::::. :* .#+. + :- -+ :#. --::-----: :* ++= .- + :*. *. .:::::*%: ++ +.-=. + + -#**----: .= -*. + -= = * +.#=+: + . .=+: =. -=. = = -+ :++: + .. .=+= .= -=. - = %- :====-:. =. .:--===- * -=. - + +-- .:--==#==-:.= + -=. = * + * =. : .= -=. = + = * + = -=. + :- = .= =: = -=. .- * + =: * * -=. + :- .+ =- :- .+ -=. .+ * * := * := -= * = :- =: .- .=: -=. =: -: * .=- + .=- -= :- =: -: --: :- :--: -=. .= =:+ ----. * :---. -= .+ --=*----------------------=*+=--=+--=+*+------------------------------------------------%+:. :: := +:- -- :. .=. =. -= -= .=: .=. .=: .+: :-- :-: -- -=. :--. --: :--: .--: .-:-: ::--. :----. .:---- .:::::::::-::::::--::::::::. */ // Hello this is Tyx2019's clone #include <bits/stdc++.h> using namespace std; #define ll long long #define debug(x) cerr << #x << " is " << x << "\n" #define hehe ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #define rep(i, a, b) for (int i = a; i <= b; i++) #define repb(i, a, b) for (int i = b; i >= a; i--) #define pii pair<int, int> #define linebreak cout << "---------------------------------------------------------\n" #define f first #define s second #define pb push_back #pragma GCC optimize("O3,unroll-loops") #pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt") // good luck const ll MS = 305, mod = 1e9+9, INF = 3e18, blk = 400; namespace { const int invalid_v_range = 1; const int invalid_k_range = 2; const int query_limit_exceeded = 3; const int invalid_xy_range = 4; const int no_edge = 5; const int answer_twice = 6; const int invalid_answer_times = 7; int N, L, ok; std::vector<int> A, B, answered; std::vector<std::vector<int>> g, dist, que; std::vector<std::pair<int, int>> p; int query_count = 0; int answer_count = 0; void wronganswer(int code) { printf("Wrong Answer [%d]\n", code); exit(0); } void dfs(int now, int pre, std::vector<std::vector<int>> &g, std::vector<int> &dist) { for (int nxt : g[now]) { if (nxt == pre) { continue; } dist[nxt] = dist[now] + 1; dfs(nxt, now, g, dist); } } } // namespace int query(int v, int k) { if (v < 1 || N < v) { wronganswer(invalid_v_range); } if (k < 1 || N - 1 < k) { wronganswer(invalid_k_range); } query_count++; if (query_count > L) { wronganswer(query_limit_exceeded); } return que[v - 1][k] + 1; } void answer(int x, int y) { if (x < 1 || N < x || y < 1 || N < y) { wronganswer(invalid_xy_range); } if (x > y) { std::swap(x, y); } answer_count++; if (answer_count > N - 1) { wronganswer(invalid_answer_times); } ok = -1; for (int i = 0; i < N - 1; i++) { if (A[i] == x && B[i] == y) { if (answered[i] != 0) { wronganswer(answer_twice); } ok = i; } } if (ok == -1) { wronganswer(no_edge); } answered[ok] = 1; } int parent[MS]; int find(int x) { if (parent[x] == x) return x; else { return parent[x] = find(parent[x]); } } bool same(int x, int y) { return find(x) == find(y); } void merge(int x, int y) { int rootx = find(x), rooty = find(y); parent[rootx] = rooty; } void solve(int n, int l) { for (int i = 1; i <= n; i++) parent[i] = i; for (int i = 1; i < n; i++) { int u = query(1, i), k = 1; while (!same(1, u)) { int v = query(u, k); answer(u, v); merge(u, v); k++; } } } int main(int argc, char **argv) { if (scanf("%d", &N) != 1) { fprintf(stderr, "Error while reading input.\n"); exit(1); } if (scanf("%d", &L) != 1) { fprintf(stderr, "Error while reading input.\n"); exit(1); } A.resize(N - 1); B.resize(N - 1); answered.resize(N - 1, 0); g.resize(N); dist.resize(N, std::vector<int>(N)); que.resize(N); for (int i = 0; i < N - 1; i++) { if (scanf("%d", &A[i]) != 1) { fprintf(stderr, "Error while reading input.\n"); exit(1); } if (scanf("%d", &B[i]) != 1) { fprintf(stderr, "Error while reading input.\n"); exit(1); } } for (int i = 0; i < N - 1; i++) { if (A[i] >= B[i]) { std::swap(A[i], B[i]); } g[A[i] - 1].emplace_back(B[i] - 1); g[B[i] - 1].emplace_back(A[i] - 1); } for (int i = 0; i < N; i++) { dist[i][i] = 0; dfs(i, -1, g, dist[i]); p.clear(); for (int j = 0; j < N; j++) { p.emplace_back(dist[i][j], j); } std::sort(p.begin(), p.end()); for (int j = 0; j < N; j++) { que[i].emplace_back(p[j].second); } } solve(N, L); if (answer_count != N - 1) { wronganswer(invalid_answer_times); } printf("Accepted: %d\n", query_count); return 0; }

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

/usr/bin/ld: /tmp/ccwEQf3R.o: in function `query(int, int)':
stub.cpp:(.text+0x0): multiple definition of `query(int, int)'; /tmp/ccLFNmU7.o:island.cpp:(.text+0x1160): first defined here
/usr/bin/ld: /tmp/ccwEQf3R.o: in function `answer(int, int)':
stub.cpp:(.text+0x100): multiple definition of `answer(int, int)'; /tmp/ccLFNmU7.o:island.cpp:(.text+0x11e0): first defined here
/usr/bin/ld: /tmp/ccwEQf3R.o: in function `main':
stub.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccLFNmU7.o:island.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status