# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
420032 |
2021-06-08T01:14:23 Z |
Ozy |
Dreaming (IOI13_dreaming) |
C++17 |
|
73 ms |
21560 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,a,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] = 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:59:9: warning: unused variable 'a' [-Wunused-variable]
59 | lli a = DSF(pos,0);
| ^
dreaming.cpp: In function 'void optimo(long long int, long long int, long long int)':
dreaming.cpp:52:9: warning: 'dd' may be used uninitialized in this function [-Wmaybe-uninitialized]
52 | if (h.des == dd) optimo(h.des,pos,max(suma,seg)+h.val);
| ^~
dreaming.cpp: In function 'long long int DSF(long long int, long long int)':
dreaming.cpp:28:16: warning: 'a' may be used uninitialized in this function [-Wmaybe-uninitialized]
28 | return a + tiem;
| ^~~~
dreaming.cpp:28:16: warning: 'tiem' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
21560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
21560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
21 ms |
7280 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
4940 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
73 ms |
21560 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |