# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
962113 | 2024-04-13T07:10:49 Z | n3rm1n | Dreaming (IOI13_dreaming) | C++17 | 1000 ms | 15344 KB |
#include<bits/stdc++.h> #include "dreaming.h" using namespace std; const long long MAXN = 1e5 + 10; vector < pair < long long, long long > > g[MAXN]; long long mark[MAXN]; long long used[MAXN]; void dfs0(long long beg) { mark[beg] = 1; used[beg] = 1; long long nb; for (long long i = 0; i < g[beg].size(); ++ i) { nb = g[beg][i].first; if(!used[nb]) dfs0(nb); } } long long maxdist = 0; long long dfs(long long beg) { used[beg] = 1; long long nb, distt; long long maxx = 0; for (long long i = 0; i < g[beg].size(); ++ i) { nb = g[beg][i].first; distt = g[beg][i].second; if(!used[nb])maxx = max(maxx, dfs(nb)+distt); } return maxx; } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { for (long long i = 0; i < M; ++ i) { g[A[i]].push_back(make_pair(B[i], T[i])); g[B[i]].push_back(make_pair(A[i], T[i])); } long long n = N; dfs0(0); long long marked1 = 0, marked0 = 0; long long mindist1 = 1e17, mindist2 = 1e17; long long currmax; long long index1 = 0, index2 = 0; for (long long i = 0; i < n; ++ i) { if(mark[i]) { memset(used, 0 ,sizeof(used)); currmax = dfs(i); if(currmax < mindist1) { mindist1 = currmax; index1 = i; } } else { memset(used, 0 ,sizeof(used)); currmax = dfs(i); if(currmax < mindist2) { mindist2 = currmax; index2 = i; } } } g[index1].push_back(make_pair(index2, L)); g[index2].push_back(make_pair(index1, L)); long long ans = 0; for (long long i = 0; i < n; ++ i) { memset(used, 0, sizeof(used)); ans = max(ans, dfs(i)); } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1054 ms | 15344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5212 KB | Output is correct |
2 | Correct | 4 ms | 5356 KB | Output is correct |
3 | Correct | 4 ms | 5212 KB | Output is correct |
4 | Correct | 4 ms | 5212 KB | Output is correct |
5 | Correct | 5 ms | 5212 KB | Output is correct |
6 | Correct | 4 ms | 5208 KB | Output is correct |
7 | Correct | 4 ms | 5208 KB | Output is correct |
8 | Correct | 4 ms | 5212 KB | Output is correct |
9 | Correct | 4 ms | 5212 KB | Output is correct |
10 | Correct | 4 ms | 5212 KB | Output is correct |
11 | Correct | 4 ms | 5356 KB | Output is correct |
12 | Correct | 4 ms | 5212 KB | Output is correct |
13 | Correct | 5 ms | 5208 KB | Output is correct |
14 | Correct | 4 ms | 5212 KB | Output is correct |
15 | Correct | 2 ms | 5212 KB | Output is correct |
16 | Correct | 4 ms | 5212 KB | Output is correct |
17 | Correct | 4 ms | 5212 KB | Output is correct |
18 | Correct | 4 ms | 5212 KB | Output is correct |
19 | Correct | 5 ms | 5344 KB | Output is correct |
20 | Correct | 4 ms | 5212 KB | Output is correct |
21 | Correct | 4 ms | 5464 KB | Output is correct |
22 | Correct | 4 ms | 5212 KB | Output is correct |
23 | Correct | 4 ms | 5212 KB | Output is correct |
24 | Correct | 4 ms | 5212 KB | Output is correct |
25 | Correct | 4 ms | 5208 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1054 ms | 15344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1056 ms | 7260 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 5212 KB | Output is correct |
2 | Correct | 4 ms | 5356 KB | Output is correct |
3 | Correct | 4 ms | 5212 KB | Output is correct |
4 | Correct | 4 ms | 5212 KB | Output is correct |
5 | Correct | 5 ms | 5212 KB | Output is correct |
6 | Correct | 4 ms | 5208 KB | Output is correct |
7 | Correct | 4 ms | 5208 KB | Output is correct |
8 | Correct | 4 ms | 5212 KB | Output is correct |
9 | Correct | 4 ms | 5212 KB | Output is correct |
10 | Correct | 4 ms | 5212 KB | Output is correct |
11 | Correct | 4 ms | 5356 KB | Output is correct |
12 | Correct | 4 ms | 5212 KB | Output is correct |
13 | Correct | 5 ms | 5208 KB | Output is correct |
14 | Correct | 4 ms | 5212 KB | Output is correct |
15 | Correct | 2 ms | 5212 KB | Output is correct |
16 | Correct | 4 ms | 5212 KB | Output is correct |
17 | Correct | 4 ms | 5212 KB | Output is correct |
18 | Correct | 4 ms | 5212 KB | Output is correct |
19 | Correct | 5 ms | 5344 KB | Output is correct |
20 | Correct | 4 ms | 5212 KB | Output is correct |
21 | Correct | 4 ms | 5464 KB | Output is correct |
22 | Correct | 4 ms | 5212 KB | Output is correct |
23 | Correct | 4 ms | 5212 KB | Output is correct |
24 | Correct | 4 ms | 5212 KB | Output is correct |
25 | Correct | 4 ms | 5208 KB | Output is correct |
26 | Correct | 24 ms | 5412 KB | Output is correct |
27 | Correct | 56 ms | 5416 KB | Output is correct |
28 | Correct | 83 ms | 5468 KB | Output is correct |
29 | Incorrect | 25 ms | 5208 KB | Output isn't correct |
30 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Execution timed out | 1054 ms | 15344 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |