# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
286807 |
2020-08-31T02:48:21 Z |
TMJN |
Dreaming (IOI13_dreaming) |
C++17 |
|
55 ms |
11000 KB |
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
struct edge{
int to,dist;
};
bool vis[100000];
int D[100000];
vector<edge>E[100000];
void dfs(int x,int from){
vis[x]=true;
for(edge e:E[x]){
if(e.to==from)continue;
dfs(e.to,x);
D[x]=max(D[x],D[e.to]+e.dist);
}
}
int travelTime(int N, int M, int L, int a[], int b[], int d[]) {
for(int i=0;i<M;i++){
E[a[i]].push_back({b[i],d[i]});
E[b[i]].push_back({a[i],d[i]});
}
vector<int>v;
for(int i=0;i<N;i++){
if(!vis[i]){
dfs(i,i);
int p=i;
int from=i;
int m=0;
int mn=D[i];
while(true){
pair<int,int>mx={-1,-1};
for(edge e:E[p]){
if(e.to==from)continue;
mx=max(mx,{D[e.to],e.to});
}
if(mx==pair<int,int>{-1,-1})break;
for(edge e:E[p]){
if(e.to==from||e.to==mx.second)continue;
m=max(m,D[e.to]+e.dist);
}
mn=min(mn,max(m,D[p]));
for(edge e:E[p]){
if(e.to==mx.second)m+=e.dist;
}
from=p;
p=mx.second;
}
v.push_back(mn);
}
}
sort(v.begin(),v.end(),greater<>());
if(v.size()==1){
return v.front();
}
else if(v.size()==2){
return v.front()+v.back()+L;
}
else{
return max(v[0]+v[1]+L,v[1]+v[2]+L+L);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
11000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
11000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
11000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
5760 KB |
Output is correct |
2 |
Correct |
27 ms |
6016 KB |
Output is correct |
3 |
Correct |
31 ms |
5880 KB |
Output is correct |
4 |
Correct |
31 ms |
5888 KB |
Output is correct |
5 |
Correct |
25 ms |
5880 KB |
Output is correct |
6 |
Correct |
27 ms |
6264 KB |
Output is correct |
7 |
Correct |
27 ms |
6008 KB |
Output is correct |
8 |
Correct |
41 ms |
5752 KB |
Output is correct |
9 |
Correct |
26 ms |
5756 KB |
Output is correct |
10 |
Correct |
26 ms |
6012 KB |
Output is correct |
11 |
Correct |
2 ms |
2688 KB |
Output is correct |
12 |
Correct |
5 ms |
3708 KB |
Output is correct |
13 |
Correct |
5 ms |
3708 KB |
Output is correct |
14 |
Correct |
5 ms |
3708 KB |
Output is correct |
15 |
Correct |
5 ms |
3708 KB |
Output is correct |
16 |
Correct |
5 ms |
3708 KB |
Output is correct |
17 |
Correct |
6 ms |
3580 KB |
Output is correct |
18 |
Correct |
6 ms |
3708 KB |
Output is correct |
19 |
Correct |
5 ms |
3708 KB |
Output is correct |
20 |
Correct |
2 ms |
2688 KB |
Output is correct |
21 |
Correct |
2 ms |
2688 KB |
Output is correct |
22 |
Correct |
2 ms |
2688 KB |
Output is correct |
23 |
Correct |
5 ms |
3708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
11000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
55 ms |
11000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |