Submission #453719

# Submission time Handle Problem Language Result Execution time Memory
453719 2021-08-04T16:02:22 Z tht2005 Dreaming (IOI13_dreaming) C++17
47 / 100
96 ms 16192 KB
#include <bits/stdc++.h>
#include "dreaming.h"
using namespace std;
 
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)
#define FORD(i,a,b) for(int i=(a),_b=(b);i>=_b;--i)
#define FORE(i,a) for(auto&i:a)
#define rep(i,a,b,z) for(int i=(a),_b=(b),_z=(z);i<=_b;i+=_z)
#define SZ(a) ((int)a.size())
#define ALL(a) a.begin(),a.end()
 
#define fs first
#define sc second
typedef pair<int,int> ii;
const int nmax=100010;
 
int f[nmax],f2[nmax],g[nmax],vst[nmax];
vector<ii>adj[nmax];
 
void dfs(int u, int p=-1)
{
    vst[u]=*vst;
    f[u]=f2[u]=0;
    FORE(x,adj[u]){
        if(x.sc==p)continue;
        dfs(x.sc,u);
        if(f[u]<f[x.sc]+x.fs){
            f2[u]=f[u];
            f[u]=f[x.sc]+x.fs;
        }
        else if(f2[u]<f[x.sc]+x.fs)
            f2[u]=f[x.sc]+x.fs;
    }
}
 
void dfs2(int u, int p=-1)
{
    FORE(x,adj[u]){
        if(x.sc==p)continue;
        if(f[u]==f[x.sc]+x.fs)g[x.sc]=max(g[u],f2[u])+x.fs;
        else g[x.sc]=max(g[u],f[u])+x.fs;
        dfs2(x.sc,u);
    }
}
 
int calc(int n, int l, const vector<int>& a)
{
    int ans=0;
    int pos=max_element(a.begin()+1,a.end())-a.begin();
    FOR(i,1,n)if(i!=pos)ans=max(ans,a[i]+a[pos]+l);
    return ans;
}
 
int travelTime(int N,int M,int L,int A[],int B[],int T[])
{
    FOR(i,0,M-1){
        ++A[i],++B[i];
        adj[A[i]].push_back({T[i],B[i]});
        adj[B[i]].push_back({T[i],A[i]});
    }
    FOR(i,1,N)if(!vst[i])++*vst,dfs(i),dfs2(i);
    FOR(i,1,N)f[i]=max(f[i],g[i]);
    vector<int>a(*vst+1,0x3f3f3f3f);
    FOR(i,1,N)a[vst[i]]=min(a[vst[i]],f[i]);
    f[0]=calc(*vst,L,a);
    return *max_element(f,f+1+N);
}
# Verdict Execution time Memory Grader output
1 Correct 57 ms 11840 KB Output is correct
2 Correct 50 ms 11596 KB Output is correct
3 Correct 33 ms 10128 KB Output is correct
4 Correct 8 ms 4016 KB Output is correct
5 Correct 6 ms 3404 KB Output is correct
6 Correct 13 ms 4672 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 24 ms 6516 KB Output is correct
9 Correct 31 ms 8524 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 58 ms 9240 KB Output is correct
12 Correct 55 ms 10588 KB Output is correct
13 Correct 2 ms 2764 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2572 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 57 ms 11840 KB Output is correct
2 Correct 50 ms 11596 KB Output is correct
3 Correct 33 ms 10128 KB Output is correct
4 Correct 8 ms 4016 KB Output is correct
5 Correct 6 ms 3404 KB Output is correct
6 Correct 13 ms 4672 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 24 ms 6516 KB Output is correct
9 Correct 31 ms 8524 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 58 ms 9240 KB Output is correct
12 Correct 55 ms 10588 KB Output is correct
13 Correct 2 ms 2764 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 2 ms 2636 KB Output is correct
27 Correct 2 ms 2636 KB Output is correct
28 Correct 2 ms 2636 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 2 ms 2636 KB Output is correct
31 Correct 2 ms 2572 KB Output is correct
32 Correct 2 ms 2636 KB Output is correct
33 Correct 2 ms 2636 KB Output is correct
34 Correct 2 ms 2636 KB Output is correct
35 Correct 2 ms 2636 KB Output is correct
36 Correct 2 ms 2636 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 2 ms 2636 KB Output is correct
39 Correct 50 ms 11872 KB Output is correct
40 Correct 56 ms 11556 KB Output is correct
41 Correct 39 ms 10088 KB Output is correct
42 Correct 8 ms 3916 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2756 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2636 KB Output is correct
47 Correct 2 ms 2636 KB Output is correct
48 Correct 2 ms 2636 KB Output is correct
49 Correct 2 ms 2636 KB Output is correct
50 Correct 2 ms 2636 KB Output is correct
51 Correct 2 ms 2636 KB Output is correct
52 Correct 2 ms 2636 KB Output is correct
53 Correct 2 ms 2636 KB Output is correct
54 Correct 2 ms 2636 KB Output is correct
55 Correct 2 ms 2636 KB Output is correct
56 Correct 2 ms 2636 KB Output is correct
57 Correct 71 ms 9284 KB Output is correct
58 Correct 67 ms 9244 KB Output is correct
59 Correct 78 ms 9344 KB Output is correct
60 Correct 66 ms 9156 KB Output is correct
61 Correct 96 ms 9208 KB Output is correct
62 Correct 79 ms 9096 KB Output is correct
63 Correct 65 ms 9028 KB Output is correct
64 Correct 62 ms 8940 KB Output is correct
65 Correct 63 ms 9028 KB Output is correct
66 Correct 66 ms 8924 KB Output is correct
67 Correct 66 ms 9284 KB Output is correct
68 Correct 67 ms 9284 KB Output is correct
69 Correct 68 ms 9232 KB Output is correct
70 Correct 72 ms 9328 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 3 ms 2764 KB Output is correct
73 Correct 3 ms 2764 KB Output is correct
74 Correct 3 ms 2764 KB Output is correct
75 Correct 0 ms 2764 KB Output is correct
76 Correct 3 ms 2764 KB Output is correct
77 Correct 4 ms 2764 KB Output is correct
78 Correct 4 ms 2764 KB Output is correct
79 Correct 3 ms 2764 KB Output is correct
80 Correct 82 ms 9272 KB Output is correct
81 Correct 67 ms 9284 KB Output is correct
82 Correct 66 ms 9116 KB Output is correct
83 Correct 90 ms 9136 KB Output is correct
84 Correct 3 ms 2764 KB Output is correct
85 Correct 3 ms 2764 KB Output is correct
86 Correct 3 ms 2764 KB Output is correct
87 Correct 3 ms 2764 KB Output is correct
88 Correct 3 ms 2764 KB Output is correct
89 Correct 3 ms 2764 KB Output is correct
90 Correct 3 ms 2756 KB Output is correct
91 Correct 3 ms 2764 KB Output is correct
92 Correct 3 ms 2764 KB Output is correct
93 Correct 3 ms 2764 KB Output is correct
94 Correct 2 ms 2636 KB Output is correct
95 Correct 2 ms 2636 KB Output is correct
96 Correct 2 ms 2636 KB Output is correct
97 Correct 2 ms 2636 KB Output is correct
98 Correct 2 ms 2636 KB Output is correct
99 Correct 2 ms 2636 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2636 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 7 ms 3404 KB Output is correct
105 Correct 13 ms 4684 KB Output is correct
106 Correct 2 ms 2636 KB Output is correct
107 Correct 24 ms 6464 KB Output is correct
108 Correct 37 ms 8640 KB Output is correct
109 Correct 2 ms 2636 KB Output is correct
110 Correct 55 ms 9252 KB Output is correct
111 Correct 65 ms 10564 KB Output is correct
112 Correct 2 ms 2636 KB Output is correct
113 Correct 93 ms 16192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 6640 KB Output is correct
2 Incorrect 22 ms 6604 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 2 ms 2636 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2572 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 2 ms 2636 KB Output is correct
27 Correct 2 ms 2792 KB Output is correct
28 Correct 3 ms 2788 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 3 ms 2764 KB Output is correct
31 Correct 3 ms 2764 KB Output is correct
32 Incorrect 2 ms 2636 KB Output isn't correct
33 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 57 ms 11840 KB Output is correct
2 Correct 50 ms 11596 KB Output is correct
3 Correct 33 ms 10128 KB Output is correct
4 Correct 8 ms 4016 KB Output is correct
5 Correct 6 ms 3404 KB Output is correct
6 Correct 13 ms 4672 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 24 ms 6516 KB Output is correct
9 Correct 31 ms 8524 KB Output is correct
10 Correct 2 ms 2636 KB Output is correct
11 Correct 58 ms 9240 KB Output is correct
12 Correct 55 ms 10588 KB Output is correct
13 Correct 2 ms 2764 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2636 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 2 ms 2636 KB Output is correct
27 Correct 2 ms 2636 KB Output is correct
28 Correct 2 ms 2636 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 2 ms 2636 KB Output is correct
31 Correct 2 ms 2572 KB Output is correct
32 Correct 2 ms 2636 KB Output is correct
33 Correct 2 ms 2636 KB Output is correct
34 Correct 2 ms 2636 KB Output is correct
35 Correct 2 ms 2636 KB Output is correct
36 Correct 2 ms 2636 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 2 ms 2636 KB Output is correct
39 Correct 50 ms 11872 KB Output is correct
40 Correct 56 ms 11556 KB Output is correct
41 Correct 39 ms 10088 KB Output is correct
42 Correct 8 ms 3916 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2756 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2636 KB Output is correct
47 Correct 2 ms 2636 KB Output is correct
48 Correct 2 ms 2636 KB Output is correct
49 Correct 2 ms 2636 KB Output is correct
50 Correct 2 ms 2636 KB Output is correct
51 Correct 2 ms 2636 KB Output is correct
52 Correct 2 ms 2636 KB Output is correct
53 Correct 2 ms 2636 KB Output is correct
54 Correct 2 ms 2636 KB Output is correct
55 Correct 2 ms 2636 KB Output is correct
56 Correct 2 ms 2636 KB Output is correct
57 Correct 71 ms 9284 KB Output is correct
58 Correct 67 ms 9244 KB Output is correct
59 Correct 78 ms 9344 KB Output is correct
60 Correct 66 ms 9156 KB Output is correct
61 Correct 96 ms 9208 KB Output is correct
62 Correct 79 ms 9096 KB Output is correct
63 Correct 65 ms 9028 KB Output is correct
64 Correct 62 ms 8940 KB Output is correct
65 Correct 63 ms 9028 KB Output is correct
66 Correct 66 ms 8924 KB Output is correct
67 Correct 66 ms 9284 KB Output is correct
68 Correct 67 ms 9284 KB Output is correct
69 Correct 68 ms 9232 KB Output is correct
70 Correct 72 ms 9328 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 3 ms 2764 KB Output is correct
73 Correct 3 ms 2764 KB Output is correct
74 Correct 3 ms 2764 KB Output is correct
75 Correct 0 ms 2764 KB Output is correct
76 Correct 3 ms 2764 KB Output is correct
77 Correct 4 ms 2764 KB Output is correct
78 Correct 4 ms 2764 KB Output is correct
79 Correct 3 ms 2764 KB Output is correct
80 Correct 82 ms 9272 KB Output is correct
81 Correct 67 ms 9284 KB Output is correct
82 Correct 66 ms 9116 KB Output is correct
83 Correct 90 ms 9136 KB Output is correct
84 Correct 3 ms 2764 KB Output is correct
85 Correct 3 ms 2764 KB Output is correct
86 Correct 3 ms 2764 KB Output is correct
87 Correct 3 ms 2764 KB Output is correct
88 Correct 3 ms 2764 KB Output is correct
89 Correct 3 ms 2764 KB Output is correct
90 Correct 3 ms 2756 KB Output is correct
91 Correct 3 ms 2764 KB Output is correct
92 Correct 3 ms 2764 KB Output is correct
93 Correct 3 ms 2764 KB Output is correct
94 Correct 2 ms 2636 KB Output is correct
95 Correct 2 ms 2636 KB Output is correct
96 Correct 2 ms 2636 KB Output is correct
97 Correct 2 ms 2636 KB Output is correct
98 Correct 2 ms 2636 KB Output is correct
99 Correct 2 ms 2636 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2636 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 7 ms 3404 KB Output is correct
105 Correct 13 ms 4684 KB Output is correct
106 Correct 2 ms 2636 KB Output is correct
107 Correct 24 ms 6464 KB Output is correct
108 Correct 37 ms 8640 KB Output is correct
109 Correct 2 ms 2636 KB Output is correct
110 Correct 55 ms 9252 KB Output is correct
111 Correct 65 ms 10564 KB Output is correct
112 Correct 2 ms 2636 KB Output is correct
113 Correct 93 ms 16192 KB Output is correct
114 Correct 26 ms 6640 KB Output is correct
115 Incorrect 22 ms 6604 KB Output isn't correct
116 Halted 0 ms 0 KB -