# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
578599 |
2022-06-17T10:53:35 Z |
1ne |
Dreaming (IOI13_dreaming) |
C++14 |
|
1000 ms |
18116 KB |
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
int ans = 0;
vector<vector<pair<int,int>>>adj(N);
for (int i = 0;i<M;++i){
adj[A[i]].push_back({B[i],T[i]});
adj[B[i]].push_back({A[i],T[i]});
}
vector<vector<int>>nodes;
vector<vector<int>>dp(N,vector<int>(2,0));
vector<int>pre(N,0);
vector<bool>visited(N,false);
for (int i = 0;i<N;++i){
if (!visited[i]){
nodes.emplace_back();
function<void(int,int)>dfs = [&](int u,int par){
visited[u] = true;
nodes.back().push_back(u);
for (auto x:adj[u]){
if (x.first == par){
pre[u] = max(pre[x.first] + x.second,pre[u]);
continue;
}
dfs(x.first,u);
if (dp[x.first][0] + x.second > dp[u][0]){
dp[u][1] = dp[u][0];
dp[u][0] = dp[x.first][0] + x.second;
}
else if (dp[x.first][0] + x.second > dp[u][1]){
dp[u][1] = dp[x.first][0] + x.second;
}
}
};
dfs(i,-1);
}
}
vector<int>pos;
for (auto x:nodes){
int maxxy =1e9;
for (auto y:x){
int minny = 0;
ans = max(ans,dp[y][0] + dp[y][1]);
function<void(int,int,int)> dfs2 = [&](int u,int par,int score){
minny = max(minny,score);
for (auto x:adj[u]){
if (x.first!=par){
dfs2(x.first,u,score + x.second);
}
}
};
dfs2(y,-1,0);
maxxy = min(maxxy,minny);
}
pos.push_back(maxxy);
}
sort(pos.begin(),pos.end());
if (pos.size() > 1){
ans = max(ans,pos[pos.size() - 1] + pos[pos.size() - 2] + L);
}
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
18116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
232 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
18116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
47 ms |
14212 KB |
Output is correct |
2 |
Incorrect |
47 ms |
14252 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
232 KB |
Output is correct |
6 |
Correct |
1 ms |
212 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
1 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
1 ms |
212 KB |
Output is correct |
17 |
Correct |
1 ms |
212 KB |
Output is correct |
18 |
Correct |
1 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
1 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
1 ms |
212 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
212 KB |
Output is correct |
25 |
Correct |
1 ms |
212 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
596 KB |
Output is correct |
28 |
Correct |
3 ms |
724 KB |
Output is correct |
29 |
Correct |
2 ms |
340 KB |
Output is correct |
30 |
Correct |
3 ms |
580 KB |
Output is correct |
31 |
Correct |
4 ms |
740 KB |
Output is correct |
32 |
Incorrect |
1 ms |
352 KB |
Output isn't correct |
33 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1094 ms |
18116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |