# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
420035 |
2021-06-08T01:24:30 Z |
Ozy |
Dreaming (IOI13_dreaming) |
C++17 |
|
79 ms |
24132 KB |
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define lli long long int
#define debugsl(a) cout << #a << " = " << a << ", "
#define debug(a) cout << #a << " = " << a << endl
#define des first
#define val second
lli act,res;
lli visitados[100002],MIN[2];
vector<pair<lli,lli> > hijos[100002],caminos[100002];
lli DSF(lli pos, lli padre) {
lli tiem = 0;
lli a = 0;
lli k = 0;
visitados[pos] = 1;
for (auto h : hijos[pos]) {
if (h.des == padre) {tiem = h.val;continue;}
a = DSF(h.des,pos);
caminos[pos].push_back({h.des,a});
if (a > k) k = a;
}
return a + tiem;
}
void optimo(lli pos, lli padre, lli suma) {
lli dd,prim = 0;
lli a,seg = 0;
for (auto h : caminos[pos]) {
if (h.val > prim){
seg = prim;
prim = h.val;
dd = h.des;
}
else if (h.val > seg) seg = h.val;
}
a = max(prim,suma);
if (a < MIN[act]) MIN[act] = a;
a = prim + seg;
if (a > res) res = a;
for (auto h : hijos[pos]) {
if (h.des == padre) continue;
if (h.des == dd) optimo(h.des,pos,(max(suma,seg)+h.val));
else optimo(h.des,pos,(max(suma,prim)+h.val));
}
}
void procesa(lli pos) {
lli a = DSF(pos,0);
optimo(pos,0,0);
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
rep(i,0,M-1) {
hijos[A[i]].push_back({B[i],T[i]});
hijos[B[i]].push_back({A[i],T[i]});
}
act = 0;
res = 0;
MIN[0] = 1ll<<62;
MIN[1] = 1ll<<62;
rep(i,1,N) {
if (act == 2) break;
if (visitados[i] == 0) {
procesa(i);
act++;
}
}
act = MIN[0] + MIN[1] + L;
res = max(res,act);
return res;
}
Compilation message
dreaming.cpp: In function 'void procesa(long long int)':
dreaming.cpp:61:9: warning: unused variable 'a' [-Wunused-variable]
61 | lli a = DSF(pos,0);
| ^
dreaming.cpp: In function 'void optimo(long long int, long long int, long long int)':
dreaming.cpp:54:9: warning: 'dd' may be used uninitialized in this function [-Wmaybe-uninitialized]
54 | if (h.des == dd) optimo(h.des,pos,(max(suma,seg)+h.val));
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
21476 KB |
Output is correct |
2 |
Correct |
67 ms |
24132 KB |
Output is correct |
3 |
Correct |
42 ms |
15668 KB |
Output is correct |
4 |
Correct |
13 ms |
7288 KB |
Output is correct |
5 |
Correct |
9 ms |
6476 KB |
Output is correct |
6 |
Correct |
16 ms |
9160 KB |
Output is correct |
7 |
Correct |
3 ms |
5004 KB |
Output is correct |
8 |
Correct |
34 ms |
11540 KB |
Output is correct |
9 |
Correct |
46 ms |
14588 KB |
Output is correct |
10 |
Correct |
4 ms |
5132 KB |
Output is correct |
11 |
Correct |
67 ms |
17808 KB |
Output is correct |
12 |
Correct |
79 ms |
21356 KB |
Output is correct |
13 |
Correct |
3 ms |
5136 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
21476 KB |
Output is correct |
2 |
Correct |
67 ms |
24132 KB |
Output is correct |
3 |
Correct |
42 ms |
15668 KB |
Output is correct |
4 |
Correct |
13 ms |
7288 KB |
Output is correct |
5 |
Correct |
9 ms |
6476 KB |
Output is correct |
6 |
Correct |
16 ms |
9160 KB |
Output is correct |
7 |
Correct |
3 ms |
5004 KB |
Output is correct |
8 |
Correct |
34 ms |
11540 KB |
Output is correct |
9 |
Correct |
46 ms |
14588 KB |
Output is correct |
10 |
Correct |
4 ms |
5132 KB |
Output is correct |
11 |
Correct |
67 ms |
17808 KB |
Output is correct |
12 |
Correct |
79 ms |
21356 KB |
Output is correct |
13 |
Correct |
3 ms |
5136 KB |
Output is correct |
14 |
Incorrect |
3 ms |
4940 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
20 ms |
7336 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
3 ms |
4940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
21476 KB |
Output is correct |
2 |
Correct |
67 ms |
24132 KB |
Output is correct |
3 |
Correct |
42 ms |
15668 KB |
Output is correct |
4 |
Correct |
13 ms |
7288 KB |
Output is correct |
5 |
Correct |
9 ms |
6476 KB |
Output is correct |
6 |
Correct |
16 ms |
9160 KB |
Output is correct |
7 |
Correct |
3 ms |
5004 KB |
Output is correct |
8 |
Correct |
34 ms |
11540 KB |
Output is correct |
9 |
Correct |
46 ms |
14588 KB |
Output is correct |
10 |
Correct |
4 ms |
5132 KB |
Output is correct |
11 |
Correct |
67 ms |
17808 KB |
Output is correct |
12 |
Correct |
79 ms |
21356 KB |
Output is correct |
13 |
Correct |
3 ms |
5136 KB |
Output is correct |
14 |
Incorrect |
3 ms |
4940 KB |
Output isn't correct |
15 |
Halted |
0 ms |
0 KB |
- |