Submission #614139

# Submission time Handle Problem Language Result Execution time Memory
614139 2022-07-30T19:45:36 Z nohaxjustsoflo Dreaming (IOI13_dreaming) C++17
47 / 100
121 ms 31224 KB
#include <bits/stdc++.h>
#include "dreaming.h"
#include <iostream>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> order_set;
mt19937 mt_rand(chrono::high_resolution_clock::now().time_since_epoch().count());
//uniform_int_distribution<int> gen; ///(min, max)
//int random() {return gen(mt_rand);}
const int mxN=1e5+5;
const int mod=998244353;
const int mxlogN=40;
const int mxK=26;
const int inf=2e9;
const int K=600;
struct edge
{
    int u,v,w;
    int other(int i)
    {
        return i^u^v;
    }
}es[mxN];
bool vis[mxN];
vector<int> cur;
multiset<int> ms[mxN];
vector<int> adj[mxN];
int down[mxN], up[mxN];
int get_max(int i)
{
    if(ms[i].empty()) return 0;
    return *ms[i].rbegin();
}
void dfs(int i, int p)
{
    vis[i]=1;
    cur.push_back(i);
    for(int e:adj[i])
    {
        int j=es[e].other(i);
        if(j==p) continue;
        dfs(j,i);
        ms[i].insert(down[j]+es[e].w);
    }
    down[i]=get_max(i);
}
void dfs2(int i, int p)
{
    for(int e:adj[i])
    {
        int j=es[e].other(i);
        if(j==p) continue;
        ms[i].erase(ms[i].find(down[j]+es[e].w));
        up[j]=es[e].w+max(get_max(i),up[i]);
        ms[i].insert(down[j]+es[e].w);
        dfs2(j,i);
    }
}

int travelTime(int N, int M, int L, int A[], int B[], int T[])
{
    int n=N, m=M;
    for(int i=0; i<m; i++)
    {
        int u=A[i],v=B[i],w=T[i];
        es[i]={u,v,w};
        adj[u].push_back(i);
        adj[v].push_back(i);
    }
    int ans=0;
    vector<int> vs;
    for(int i=0; i<n; i++)
    {
        if(!vis[i])
        {
            dfs(i,i);
            dfs2(i,i);
            int mx=0, mn=inf;
            for(int i:cur)
            {
                mx=max(mx,max(down[i],up[i]));
                mn=min(mn,max(down[i],up[i]));
            }
            ans=max(ans,mx);
            vs.push_back(mn);
            cur.clear();
        }
    }
    sort(vs.begin(),vs.end());
    int sz=vs.size();
    if(sz<3)
    {
        if(sz==1) return ans;
        return max(ans,vs[0]+vs[1]+L);
    }
    return max(ans,vs[sz-2]+vs[sz-3]+L+L);
}
/*
int main()
{

}*/
/*
7 3
4 1 3 4 0 2 3
*/
# Verdict Execution time Memory Grader output
1 Correct 71 ms 24560 KB Output is correct
2 Correct 90 ms 24084 KB Output is correct
3 Correct 48 ms 20756 KB Output is correct
4 Correct 12 ms 9856 KB Output is correct
5 Correct 10 ms 8908 KB Output is correct
6 Correct 19 ms 11096 KB Output is correct
7 Correct 6 ms 7376 KB Output is correct
8 Correct 40 ms 14508 KB Output is correct
9 Correct 43 ms 17992 KB Output is correct
10 Correct 4 ms 7504 KB Output is correct
11 Correct 73 ms 19984 KB Output is correct
12 Correct 90 ms 22064 KB Output is correct
13 Correct 4 ms 7508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 3 ms 7380 KB Output is correct
5 Correct 4 ms 7296 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 4 ms 7364 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 5 ms 7380 KB Output is correct
10 Correct 5 ms 7420 KB Output is correct
11 Correct 4 ms 7380 KB Output is correct
12 Correct 5 ms 7380 KB Output is correct
13 Correct 4 ms 7380 KB Output is correct
14 Correct 4 ms 7316 KB Output is correct
15 Correct 4 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 4 ms 7380 KB Output is correct
18 Correct 4 ms 7380 KB Output is correct
19 Correct 4 ms 7380 KB Output is correct
20 Correct 4 ms 7400 KB Output is correct
21 Correct 4 ms 7364 KB Output is correct
22 Correct 4 ms 7380 KB Output is correct
23 Correct 4 ms 7380 KB Output is correct
24 Correct 5 ms 7404 KB Output is correct
25 Correct 5 ms 7372 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 71 ms 24560 KB Output is correct
2 Correct 90 ms 24084 KB Output is correct
3 Correct 48 ms 20756 KB Output is correct
4 Correct 12 ms 9856 KB Output is correct
5 Correct 10 ms 8908 KB Output is correct
6 Correct 19 ms 11096 KB Output is correct
7 Correct 6 ms 7376 KB Output is correct
8 Correct 40 ms 14508 KB Output is correct
9 Correct 43 ms 17992 KB Output is correct
10 Correct 4 ms 7504 KB Output is correct
11 Correct 73 ms 19984 KB Output is correct
12 Correct 90 ms 22064 KB Output is correct
13 Correct 4 ms 7508 KB Output is correct
14 Correct 4 ms 7380 KB Output is correct
15 Correct 4 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 3 ms 7380 KB Output is correct
18 Correct 4 ms 7296 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7364 KB Output is correct
21 Correct 4 ms 7380 KB Output is correct
22 Correct 5 ms 7380 KB Output is correct
23 Correct 5 ms 7420 KB Output is correct
24 Correct 4 ms 7380 KB Output is correct
25 Correct 5 ms 7380 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 4 ms 7316 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7380 KB Output is correct
31 Correct 4 ms 7380 KB Output is correct
32 Correct 4 ms 7380 KB Output is correct
33 Correct 4 ms 7400 KB Output is correct
34 Correct 4 ms 7364 KB Output is correct
35 Correct 4 ms 7380 KB Output is correct
36 Correct 4 ms 7380 KB Output is correct
37 Correct 5 ms 7404 KB Output is correct
38 Correct 5 ms 7372 KB Output is correct
39 Correct 74 ms 24516 KB Output is correct
40 Correct 72 ms 24132 KB Output is correct
41 Correct 47 ms 20684 KB Output is correct
42 Correct 15 ms 9812 KB Output is correct
43 Correct 5 ms 7380 KB Output is correct
44 Correct 4 ms 7380 KB Output is correct
45 Correct 4 ms 7380 KB Output is correct
46 Correct 5 ms 7380 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 4 ms 7380 KB Output is correct
49 Correct 4 ms 7380 KB Output is correct
50 Correct 4 ms 7380 KB Output is correct
51 Correct 4 ms 7380 KB Output is correct
52 Correct 4 ms 7380 KB Output is correct
53 Correct 3 ms 7368 KB Output is correct
54 Correct 4 ms 7380 KB Output is correct
55 Correct 4 ms 7380 KB Output is correct
56 Correct 5 ms 7380 KB Output is correct
57 Correct 121 ms 20020 KB Output is correct
58 Correct 104 ms 19904 KB Output is correct
59 Correct 99 ms 20168 KB Output is correct
60 Correct 97 ms 20116 KB Output is correct
61 Correct 96 ms 20460 KB Output is correct
62 Correct 107 ms 20536 KB Output is correct
63 Correct 94 ms 20144 KB Output is correct
64 Correct 117 ms 20228 KB Output is correct
65 Correct 106 ms 20512 KB Output is correct
66 Correct 102 ms 20420 KB Output is correct
67 Correct 121 ms 20220 KB Output is correct
68 Correct 110 ms 20188 KB Output is correct
69 Correct 116 ms 20412 KB Output is correct
70 Correct 95 ms 20296 KB Output is correct
71 Correct 4 ms 7372 KB Output is correct
72 Correct 5 ms 7768 KB Output is correct
73 Correct 7 ms 7764 KB Output is correct
74 Correct 5 ms 7760 KB Output is correct
75 Correct 5 ms 7764 KB Output is correct
76 Correct 8 ms 7760 KB Output is correct
77 Correct 8 ms 7764 KB Output is correct
78 Correct 6 ms 7764 KB Output is correct
79 Correct 6 ms 7764 KB Output is correct
80 Correct 111 ms 20228 KB Output is correct
81 Correct 96 ms 20056 KB Output is correct
82 Correct 104 ms 20396 KB Output is correct
83 Correct 97 ms 20420 KB Output is correct
84 Correct 6 ms 7636 KB Output is correct
85 Correct 6 ms 7676 KB Output is correct
86 Correct 7 ms 7636 KB Output is correct
87 Correct 7 ms 7636 KB Output is correct
88 Correct 6 ms 7716 KB Output is correct
89 Correct 5 ms 7608 KB Output is correct
90 Correct 6 ms 7636 KB Output is correct
91 Correct 6 ms 7764 KB Output is correct
92 Correct 6 ms 7636 KB Output is correct
93 Correct 6 ms 7636 KB Output is correct
94 Correct 4 ms 7380 KB Output is correct
95 Correct 4 ms 7372 KB Output is correct
96 Correct 4 ms 7380 KB Output is correct
97 Correct 4 ms 7380 KB Output is correct
98 Correct 4 ms 7380 KB Output is correct
99 Correct 4 ms 7380 KB Output is correct
100 Correct 4 ms 7360 KB Output is correct
101 Correct 5 ms 7380 KB Output is correct
102 Correct 4 ms 7380 KB Output is correct
103 Correct 4 ms 7380 KB Output is correct
104 Correct 9 ms 8964 KB Output is correct
105 Correct 16 ms 11092 KB Output is correct
106 Correct 4 ms 7380 KB Output is correct
107 Correct 32 ms 14544 KB Output is correct
108 Correct 47 ms 17912 KB Output is correct
109 Correct 4 ms 7500 KB Output is correct
110 Correct 96 ms 19992 KB Output is correct
111 Correct 97 ms 22168 KB Output is correct
112 Correct 6 ms 7540 KB Output is correct
113 Correct 117 ms 31224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 12936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 7380 KB Output is correct
2 Correct 4 ms 7380 KB Output is correct
3 Correct 4 ms 7380 KB Output is correct
4 Correct 3 ms 7380 KB Output is correct
5 Correct 4 ms 7296 KB Output is correct
6 Correct 4 ms 7372 KB Output is correct
7 Correct 4 ms 7364 KB Output is correct
8 Correct 4 ms 7380 KB Output is correct
9 Correct 5 ms 7380 KB Output is correct
10 Correct 5 ms 7420 KB Output is correct
11 Correct 4 ms 7380 KB Output is correct
12 Correct 5 ms 7380 KB Output is correct
13 Correct 4 ms 7380 KB Output is correct
14 Correct 4 ms 7316 KB Output is correct
15 Correct 4 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 4 ms 7380 KB Output is correct
18 Correct 4 ms 7380 KB Output is correct
19 Correct 4 ms 7380 KB Output is correct
20 Correct 4 ms 7400 KB Output is correct
21 Correct 4 ms 7364 KB Output is correct
22 Correct 4 ms 7380 KB Output is correct
23 Correct 4 ms 7380 KB Output is correct
24 Correct 5 ms 7404 KB Output is correct
25 Correct 5 ms 7372 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 5 ms 7508 KB Output is correct
28 Correct 5 ms 7640 KB Output is correct
29 Incorrect 7 ms 7508 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 71 ms 24560 KB Output is correct
2 Correct 90 ms 24084 KB Output is correct
3 Correct 48 ms 20756 KB Output is correct
4 Correct 12 ms 9856 KB Output is correct
5 Correct 10 ms 8908 KB Output is correct
6 Correct 19 ms 11096 KB Output is correct
7 Correct 6 ms 7376 KB Output is correct
8 Correct 40 ms 14508 KB Output is correct
9 Correct 43 ms 17992 KB Output is correct
10 Correct 4 ms 7504 KB Output is correct
11 Correct 73 ms 19984 KB Output is correct
12 Correct 90 ms 22064 KB Output is correct
13 Correct 4 ms 7508 KB Output is correct
14 Correct 4 ms 7380 KB Output is correct
15 Correct 4 ms 7380 KB Output is correct
16 Correct 4 ms 7380 KB Output is correct
17 Correct 3 ms 7380 KB Output is correct
18 Correct 4 ms 7296 KB Output is correct
19 Correct 4 ms 7372 KB Output is correct
20 Correct 4 ms 7364 KB Output is correct
21 Correct 4 ms 7380 KB Output is correct
22 Correct 5 ms 7380 KB Output is correct
23 Correct 5 ms 7420 KB Output is correct
24 Correct 4 ms 7380 KB Output is correct
25 Correct 5 ms 7380 KB Output is correct
26 Correct 4 ms 7380 KB Output is correct
27 Correct 4 ms 7316 KB Output is correct
28 Correct 4 ms 7380 KB Output is correct
29 Correct 4 ms 7380 KB Output is correct
30 Correct 4 ms 7380 KB Output is correct
31 Correct 4 ms 7380 KB Output is correct
32 Correct 4 ms 7380 KB Output is correct
33 Correct 4 ms 7400 KB Output is correct
34 Correct 4 ms 7364 KB Output is correct
35 Correct 4 ms 7380 KB Output is correct
36 Correct 4 ms 7380 KB Output is correct
37 Correct 5 ms 7404 KB Output is correct
38 Correct 5 ms 7372 KB Output is correct
39 Correct 74 ms 24516 KB Output is correct
40 Correct 72 ms 24132 KB Output is correct
41 Correct 47 ms 20684 KB Output is correct
42 Correct 15 ms 9812 KB Output is correct
43 Correct 5 ms 7380 KB Output is correct
44 Correct 4 ms 7380 KB Output is correct
45 Correct 4 ms 7380 KB Output is correct
46 Correct 5 ms 7380 KB Output is correct
47 Correct 4 ms 7380 KB Output is correct
48 Correct 4 ms 7380 KB Output is correct
49 Correct 4 ms 7380 KB Output is correct
50 Correct 4 ms 7380 KB Output is correct
51 Correct 4 ms 7380 KB Output is correct
52 Correct 4 ms 7380 KB Output is correct
53 Correct 3 ms 7368 KB Output is correct
54 Correct 4 ms 7380 KB Output is correct
55 Correct 4 ms 7380 KB Output is correct
56 Correct 5 ms 7380 KB Output is correct
57 Correct 121 ms 20020 KB Output is correct
58 Correct 104 ms 19904 KB Output is correct
59 Correct 99 ms 20168 KB Output is correct
60 Correct 97 ms 20116 KB Output is correct
61 Correct 96 ms 20460 KB Output is correct
62 Correct 107 ms 20536 KB Output is correct
63 Correct 94 ms 20144 KB Output is correct
64 Correct 117 ms 20228 KB Output is correct
65 Correct 106 ms 20512 KB Output is correct
66 Correct 102 ms 20420 KB Output is correct
67 Correct 121 ms 20220 KB Output is correct
68 Correct 110 ms 20188 KB Output is correct
69 Correct 116 ms 20412 KB Output is correct
70 Correct 95 ms 20296 KB Output is correct
71 Correct 4 ms 7372 KB Output is correct
72 Correct 5 ms 7768 KB Output is correct
73 Correct 7 ms 7764 KB Output is correct
74 Correct 5 ms 7760 KB Output is correct
75 Correct 5 ms 7764 KB Output is correct
76 Correct 8 ms 7760 KB Output is correct
77 Correct 8 ms 7764 KB Output is correct
78 Correct 6 ms 7764 KB Output is correct
79 Correct 6 ms 7764 KB Output is correct
80 Correct 111 ms 20228 KB Output is correct
81 Correct 96 ms 20056 KB Output is correct
82 Correct 104 ms 20396 KB Output is correct
83 Correct 97 ms 20420 KB Output is correct
84 Correct 6 ms 7636 KB Output is correct
85 Correct 6 ms 7676 KB Output is correct
86 Correct 7 ms 7636 KB Output is correct
87 Correct 7 ms 7636 KB Output is correct
88 Correct 6 ms 7716 KB Output is correct
89 Correct 5 ms 7608 KB Output is correct
90 Correct 6 ms 7636 KB Output is correct
91 Correct 6 ms 7764 KB Output is correct
92 Correct 6 ms 7636 KB Output is correct
93 Correct 6 ms 7636 KB Output is correct
94 Correct 4 ms 7380 KB Output is correct
95 Correct 4 ms 7372 KB Output is correct
96 Correct 4 ms 7380 KB Output is correct
97 Correct 4 ms 7380 KB Output is correct
98 Correct 4 ms 7380 KB Output is correct
99 Correct 4 ms 7380 KB Output is correct
100 Correct 4 ms 7360 KB Output is correct
101 Correct 5 ms 7380 KB Output is correct
102 Correct 4 ms 7380 KB Output is correct
103 Correct 4 ms 7380 KB Output is correct
104 Correct 9 ms 8964 KB Output is correct
105 Correct 16 ms 11092 KB Output is correct
106 Correct 4 ms 7380 KB Output is correct
107 Correct 32 ms 14544 KB Output is correct
108 Correct 47 ms 17912 KB Output is correct
109 Correct 4 ms 7500 KB Output is correct
110 Correct 96 ms 19992 KB Output is correct
111 Correct 97 ms 22168 KB Output is correct
112 Correct 6 ms 7540 KB Output is correct
113 Correct 117 ms 31224 KB Output is correct
114 Incorrect 27 ms 12936 KB Output isn't correct
115 Halted 0 ms 0 KB -