# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
741673 | 2023-05-14T14:17:21 Z | vjudge1 | Dreaming (IOI13_dreaming) | C++17 | 39 ms | 11088 KB |
#include <bits/stdc++.h> #include "dreaming.h" using namespace std; #define endl '\n' #define ll long long #define all(x) x.begin(), x.end() vector<pair<int, int>> g[100005]; ll sz[100005]; vector<int> group; bool visited[100005]; int getSize(int n, int p = -1) { visited[n] = 1; group.push_back(n); sz[n] = 0; for (auto x : g[n]) { if (x.first == p) continue; sz[n] += getSize(x.first, n) + x.second; } return sz[n]; } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { for (int i = 0; i < M; i++) { g[A[i]].push_back({B[i], T[i]}); g[B[i]].push_back({A[i], T[i]}); } vector<int> groups; for (int i = 0; i < N; i++) { if (visited[i]) continue; group.clear(); getSize(i); int diff = INT_MAX; for (auto x : group) { if (abs(sz[i] / 2 - sz[x]) < diff) { diff = abs(sz[i] / 2 - sz[x]); } } groups.push_back(diff); } sort(all(groups)); reverse(all(groups)); int ans = 0; for (int i = 1; i < groups.size(); i++) { ans = max(ans, groups[i] + groups[0] + L); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 39 ms | 11088 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 39 ms | 11088 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 18 ms | 6104 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 2644 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 39 ms | 11088 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |