# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
578594 |
2022-06-17T10:34:25 Z |
1ne |
Dreaming (IOI13_dreaming) |
C++14 |
|
1000 ms |
18064 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;
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 |
1084 ms |
18064 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
18064 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
49 ms |
14208 KB |
Output is correct |
2 |
Incorrect |
46 ms |
14704 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
1084 ms |
18064 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |