# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
844714 | 2023-09-05T17:56:40 Z | detaomega | Dreaming (IOI13_dreaming) | C++14 | 21 ms | 8016 KB |
#include <iostream> #include <algorithm> #include <vector> #include <queue> using namespace std; #include "dreaming.h" const int maxn = 1e5 + 5; vector<pair<int,int>> G[maxn]; int getDiameter(int n) { queue<int> q; vector<int> dis(maxn, -1); q.push(1); dis[1] = 0; while (q.size()) { int u = q.front(); q.pop(); for (auto e : G[u]) { int v = e.first; if (dis[v] == -1) { dis[v] = dis[u] + e.second; q.push(v); } } } int now = 0, mx = 0; for (int i = 1; i <= n; i++) { if (mx < dis[i]) { mx = dis[i]; now = i; } dis[i] = -1; } q.push(now); dis[now] = 0; while (q.size()) { int u = q.front(); q.pop(); for (auto e : G[u]) { int v = e.first; if (dis[v] == -1) { dis[v] = dis[u] + e.second; q.push(v); } } } return *max_element(dis.begin(), dis.end()); } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { for (int i = 0; i < M; i++) { G[++A[i]].emplace_back(++B[i], T[i]); } if (N == 1) { return 0; } if (N == M + 1) { return getDiameter(N); } if (N == 2) { return L; } if (M == 0) { return L * 2; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 8016 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 3672 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 8016 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 8 ms | 5212 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 1 ms | 3672 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Incorrect | 21 ms | 8016 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |