제출 #249451

#제출 시각아이디문제언어결과실행 시간메모리
249451shenxyMeetings (JOI19_meetings)C++14
29 / 100
3084 ms8868 KiB
#include "meetings.h" #include <algorithm> using namespace std; void Solve(int N) { int lca[N][N]; for (int i = 1; i < N; ++i) { for (int j = i + 1; j < N; ++j) lca[i][j] = lca[j][i] = Query(0, i, j); } for (int i = 1; i < N; ++i) lca[0][i] = lca[i][0] = 0; int depth[N], parent[N]; fill_n(depth, N, N + 1); for (int i = 0; i < N; ++i) { for (int j = 0; j < N; ++j) { if (depth[j] == N + 1) { depth[j] = 0; parent[j] = -1; for (int k = 0; k < N; ++k) { if (k == j || lca[j][k] == j) continue; if (depth[lca[j][k]] + 1 > depth[j]) depth[j] = min(N, depth[lca[j][k]]) + 1, parent[j] = lca[j][k]; } } } } for (int i = 0; i < N; ++i) { if (parent[i] != -1) Bridge(min(i, parent[i]), max(i, parent[i])); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...