Submission #541793

# Submission time Handle Problem Language Result Execution time Memory
541793 2022-03-24T11:53:25 Z Sho10 Dreaming (IOI13_dreaming) C++17
47 / 100
788 ms 40196 KB
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho
#include "dreaming.h"
using ll=int;
using ld=long double;
int const INF=1000000005;
//ll const LINF=1000000000000000005;
ll const mod=1000000007;
ld const PI=3.14159265359;
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
int const mxN=1000005;
bool viz[mxN];
vector<pair<ll,ll>>g[1000005];
vector<ll>comp;
ll bg;
map<ll,ll> bfs(ll node){
map<ll,ll>dist;
dist[node]=0;
vector<bool>check(mxN,false);
check[node]=true;
queue<ll>q;
q.push(node);
ll mx=0;
while(!q.empty()){
    ll x=q.front();
    comp.pb(x);
    viz[x]=1;
     q.pop();
    for(auto it : g[x]){
        if(!check[it.f]){
            dist[it.f]=dist[x]+it.s;
            q.push(it.f);
            check[it.f]=true;
            if(dist[it.f]>mx){
                mx=dist[it.f];
                bg=it.f;
            }
        }
    }
}
return dist;
}
int travelTime(int n,int m,int l,int a[], int b[], int t[]){
    for(ll i=0;i<n;i++)
    {
        g[i].clear();
        viz[i]=0;
    }
for(ll i=0;i<m;i++)
{
    g[a[i]].pb(mp(b[i],t[i]));
    g[b[i]].pb(mp(a[i],t[i]));
}
vector<pair<ll,ll>>v;
for(ll i=0;i<n;i++)
{
    if(viz[i]){
        continue;
    }
    bg=i;
    bfs(i);
    map<ll,ll>X=bfs(bg);
    comp.clear();
    map<ll,ll>Y=bfs(bg);
    ll ans=bg;
    ll mx=max(X[ans],Y[ans]);
    for(auto it : comp){
        if(max(X[it],Y[it])<mx){
            mx=max(X[it],Y[it]);
            ans=it;
        }
    }
    v.pb(mp(mx,ans));
}
sort(v.begin(),v.end());
for(ll i=1;i<v.size();i++)
{
    g[v[i].s].pb(mp(v[0].s,l));
    g[v[0].s].pb(mp(v[i].s,l));
}
bg=0;
bfs(0);
map<ll,ll>X=bfs(bg);
map<ll,ll>Y=bfs(bg);
int ans=0;
for(ll i=0;i<n;i++)
{
    ans=max(ans,max(X[i],Y[i]));
}
return ans;
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:83:13: warning: comparison of integer expressions of different signedness: 'll' {aka 'int'} and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 | for(ll i=1;i<v.size();i++)
      |            ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 441 ms 38572 KB Output is correct
2 Correct 447 ms 38468 KB Output is correct
3 Correct 282 ms 33204 KB Output is correct
4 Correct 61 ms 26012 KB Output is correct
5 Correct 49 ms 25412 KB Output is correct
6 Correct 101 ms 26908 KB Output is correct
7 Correct 12 ms 23892 KB Output is correct
8 Correct 176 ms 29884 KB Output is correct
9 Correct 223 ms 31484 KB Output is correct
10 Correct 14 ms 23968 KB Output is correct
11 Correct 350 ms 34548 KB Output is correct
12 Correct 398 ms 35896 KB Output is correct
13 Correct 14 ms 24020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23956 KB Output is correct
2 Correct 14 ms 24020 KB Output is correct
3 Correct 12 ms 23952 KB Output is correct
4 Correct 12 ms 24020 KB Output is correct
5 Correct 13 ms 24020 KB Output is correct
6 Correct 14 ms 24052 KB Output is correct
7 Correct 13 ms 24020 KB Output is correct
8 Correct 12 ms 24020 KB Output is correct
9 Correct 12 ms 24020 KB Output is correct
10 Correct 14 ms 23984 KB Output is correct
11 Correct 13 ms 23960 KB Output is correct
12 Correct 12 ms 24020 KB Output is correct
13 Correct 12 ms 24020 KB Output is correct
14 Correct 12 ms 23972 KB Output is correct
15 Correct 12 ms 24044 KB Output is correct
16 Correct 12 ms 24020 KB Output is correct
17 Correct 12 ms 24020 KB Output is correct
18 Correct 12 ms 23984 KB Output is correct
19 Correct 12 ms 24024 KB Output is correct
20 Correct 14 ms 24020 KB Output is correct
21 Correct 12 ms 24028 KB Output is correct
22 Correct 12 ms 24020 KB Output is correct
23 Correct 13 ms 24020 KB Output is correct
24 Correct 12 ms 24052 KB Output is correct
25 Correct 12 ms 24020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 441 ms 38572 KB Output is correct
2 Correct 447 ms 38468 KB Output is correct
3 Correct 282 ms 33204 KB Output is correct
4 Correct 61 ms 26012 KB Output is correct
5 Correct 49 ms 25412 KB Output is correct
6 Correct 101 ms 26908 KB Output is correct
7 Correct 12 ms 23892 KB Output is correct
8 Correct 176 ms 29884 KB Output is correct
9 Correct 223 ms 31484 KB Output is correct
10 Correct 14 ms 23968 KB Output is correct
11 Correct 350 ms 34548 KB Output is correct
12 Correct 398 ms 35896 KB Output is correct
13 Correct 14 ms 24020 KB Output is correct
14 Correct 14 ms 23956 KB Output is correct
15 Correct 14 ms 24020 KB Output is correct
16 Correct 12 ms 23952 KB Output is correct
17 Correct 12 ms 24020 KB Output is correct
18 Correct 13 ms 24020 KB Output is correct
19 Correct 14 ms 24052 KB Output is correct
20 Correct 13 ms 24020 KB Output is correct
21 Correct 12 ms 24020 KB Output is correct
22 Correct 12 ms 24020 KB Output is correct
23 Correct 14 ms 23984 KB Output is correct
24 Correct 13 ms 23960 KB Output is correct
25 Correct 12 ms 24020 KB Output is correct
26 Correct 12 ms 24020 KB Output is correct
27 Correct 12 ms 23972 KB Output is correct
28 Correct 12 ms 24044 KB Output is correct
29 Correct 12 ms 24020 KB Output is correct
30 Correct 12 ms 24020 KB Output is correct
31 Correct 12 ms 23984 KB Output is correct
32 Correct 12 ms 24024 KB Output is correct
33 Correct 14 ms 24020 KB Output is correct
34 Correct 12 ms 24028 KB Output is correct
35 Correct 12 ms 24020 KB Output is correct
36 Correct 13 ms 24020 KB Output is correct
37 Correct 12 ms 24052 KB Output is correct
38 Correct 12 ms 24020 KB Output is correct
39 Correct 480 ms 38540 KB Output is correct
40 Correct 451 ms 38576 KB Output is correct
41 Correct 307 ms 33172 KB Output is correct
42 Correct 59 ms 25908 KB Output is correct
43 Correct 12 ms 24060 KB Output is correct
44 Correct 12 ms 24020 KB Output is correct
45 Correct 12 ms 24020 KB Output is correct
46 Correct 12 ms 24048 KB Output is correct
47 Correct 14 ms 23988 KB Output is correct
48 Correct 12 ms 23928 KB Output is correct
49 Correct 13 ms 23996 KB Output is correct
50 Correct 13 ms 23940 KB Output is correct
51 Correct 13 ms 24020 KB Output is correct
52 Correct 12 ms 24020 KB Output is correct
53 Correct 14 ms 24020 KB Output is correct
54 Correct 14 ms 24020 KB Output is correct
55 Correct 12 ms 24020 KB Output is correct
56 Correct 13 ms 24020 KB Output is correct
57 Correct 523 ms 39712 KB Output is correct
58 Correct 528 ms 39872 KB Output is correct
59 Correct 515 ms 39604 KB Output is correct
60 Correct 486 ms 39740 KB Output is correct
61 Correct 531 ms 39520 KB Output is correct
62 Correct 484 ms 39888 KB Output is correct
63 Correct 504 ms 40196 KB Output is correct
64 Correct 601 ms 39420 KB Output is correct
65 Correct 590 ms 39328 KB Output is correct
66 Correct 617 ms 39344 KB Output is correct
67 Correct 628 ms 39556 KB Output is correct
68 Correct 576 ms 39600 KB Output is correct
69 Correct 551 ms 39720 KB Output is correct
70 Correct 589 ms 39720 KB Output is correct
71 Correct 12 ms 24020 KB Output is correct
72 Correct 20 ms 24304 KB Output is correct
73 Correct 20 ms 24404 KB Output is correct
74 Correct 21 ms 24376 KB Output is correct
75 Correct 20 ms 24384 KB Output is correct
76 Correct 21 ms 24404 KB Output is correct
77 Correct 22 ms 24344 KB Output is correct
78 Correct 22 ms 24404 KB Output is correct
79 Correct 34 ms 24368 KB Output is correct
80 Correct 567 ms 39784 KB Output is correct
81 Correct 613 ms 39632 KB Output is correct
82 Correct 614 ms 39596 KB Output is correct
83 Correct 607 ms 39536 KB Output is correct
84 Correct 19 ms 24316 KB Output is correct
85 Correct 21 ms 24152 KB Output is correct
86 Correct 19 ms 24232 KB Output is correct
87 Correct 20 ms 24236 KB Output is correct
88 Correct 22 ms 24276 KB Output is correct
89 Correct 23 ms 24364 KB Output is correct
90 Correct 24 ms 24332 KB Output is correct
91 Correct 26 ms 24344 KB Output is correct
92 Correct 22 ms 24276 KB Output is correct
93 Correct 23 ms 24320 KB Output is correct
94 Correct 13 ms 24016 KB Output is correct
95 Correct 13 ms 24020 KB Output is correct
96 Correct 13 ms 24036 KB Output is correct
97 Correct 14 ms 23932 KB Output is correct
98 Correct 14 ms 24020 KB Output is correct
99 Correct 16 ms 24020 KB Output is correct
100 Correct 13 ms 23980 KB Output is correct
101 Correct 13 ms 24020 KB Output is correct
102 Correct 14 ms 24160 KB Output is correct
103 Correct 14 ms 24080 KB Output is correct
104 Correct 51 ms 25360 KB Output is correct
105 Correct 97 ms 26808 KB Output is correct
106 Correct 15 ms 23876 KB Output is correct
107 Correct 214 ms 29980 KB Output is correct
108 Correct 268 ms 31428 KB Output is correct
109 Correct 14 ms 23892 KB Output is correct
110 Correct 390 ms 34520 KB Output is correct
111 Correct 459 ms 35872 KB Output is correct
112 Correct 14 ms 24020 KB Output is correct
113 Correct 715 ms 38868 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 788 ms 39256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 14 ms 23956 KB Output is correct
2 Correct 14 ms 24020 KB Output is correct
3 Correct 12 ms 23952 KB Output is correct
4 Correct 12 ms 24020 KB Output is correct
5 Correct 13 ms 24020 KB Output is correct
6 Correct 14 ms 24052 KB Output is correct
7 Correct 13 ms 24020 KB Output is correct
8 Correct 12 ms 24020 KB Output is correct
9 Correct 12 ms 24020 KB Output is correct
10 Correct 14 ms 23984 KB Output is correct
11 Correct 13 ms 23960 KB Output is correct
12 Correct 12 ms 24020 KB Output is correct
13 Correct 12 ms 24020 KB Output is correct
14 Correct 12 ms 23972 KB Output is correct
15 Correct 12 ms 24044 KB Output is correct
16 Correct 12 ms 24020 KB Output is correct
17 Correct 12 ms 24020 KB Output is correct
18 Correct 12 ms 23984 KB Output is correct
19 Correct 12 ms 24024 KB Output is correct
20 Correct 14 ms 24020 KB Output is correct
21 Correct 12 ms 24028 KB Output is correct
22 Correct 12 ms 24020 KB Output is correct
23 Correct 13 ms 24020 KB Output is correct
24 Correct 12 ms 24052 KB Output is correct
25 Correct 12 ms 24020 KB Output is correct
26 Correct 15 ms 24020 KB Output is correct
27 Correct 18 ms 24140 KB Output is correct
28 Correct 25 ms 24340 KB Output is correct
29 Incorrect 14 ms 24020 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 441 ms 38572 KB Output is correct
2 Correct 447 ms 38468 KB Output is correct
3 Correct 282 ms 33204 KB Output is correct
4 Correct 61 ms 26012 KB Output is correct
5 Correct 49 ms 25412 KB Output is correct
6 Correct 101 ms 26908 KB Output is correct
7 Correct 12 ms 23892 KB Output is correct
8 Correct 176 ms 29884 KB Output is correct
9 Correct 223 ms 31484 KB Output is correct
10 Correct 14 ms 23968 KB Output is correct
11 Correct 350 ms 34548 KB Output is correct
12 Correct 398 ms 35896 KB Output is correct
13 Correct 14 ms 24020 KB Output is correct
14 Correct 14 ms 23956 KB Output is correct
15 Correct 14 ms 24020 KB Output is correct
16 Correct 12 ms 23952 KB Output is correct
17 Correct 12 ms 24020 KB Output is correct
18 Correct 13 ms 24020 KB Output is correct
19 Correct 14 ms 24052 KB Output is correct
20 Correct 13 ms 24020 KB Output is correct
21 Correct 12 ms 24020 KB Output is correct
22 Correct 12 ms 24020 KB Output is correct
23 Correct 14 ms 23984 KB Output is correct
24 Correct 13 ms 23960 KB Output is correct
25 Correct 12 ms 24020 KB Output is correct
26 Correct 12 ms 24020 KB Output is correct
27 Correct 12 ms 23972 KB Output is correct
28 Correct 12 ms 24044 KB Output is correct
29 Correct 12 ms 24020 KB Output is correct
30 Correct 12 ms 24020 KB Output is correct
31 Correct 12 ms 23984 KB Output is correct
32 Correct 12 ms 24024 KB Output is correct
33 Correct 14 ms 24020 KB Output is correct
34 Correct 12 ms 24028 KB Output is correct
35 Correct 12 ms 24020 KB Output is correct
36 Correct 13 ms 24020 KB Output is correct
37 Correct 12 ms 24052 KB Output is correct
38 Correct 12 ms 24020 KB Output is correct
39 Correct 480 ms 38540 KB Output is correct
40 Correct 451 ms 38576 KB Output is correct
41 Correct 307 ms 33172 KB Output is correct
42 Correct 59 ms 25908 KB Output is correct
43 Correct 12 ms 24060 KB Output is correct
44 Correct 12 ms 24020 KB Output is correct
45 Correct 12 ms 24020 KB Output is correct
46 Correct 12 ms 24048 KB Output is correct
47 Correct 14 ms 23988 KB Output is correct
48 Correct 12 ms 23928 KB Output is correct
49 Correct 13 ms 23996 KB Output is correct
50 Correct 13 ms 23940 KB Output is correct
51 Correct 13 ms 24020 KB Output is correct
52 Correct 12 ms 24020 KB Output is correct
53 Correct 14 ms 24020 KB Output is correct
54 Correct 14 ms 24020 KB Output is correct
55 Correct 12 ms 24020 KB Output is correct
56 Correct 13 ms 24020 KB Output is correct
57 Correct 523 ms 39712 KB Output is correct
58 Correct 528 ms 39872 KB Output is correct
59 Correct 515 ms 39604 KB Output is correct
60 Correct 486 ms 39740 KB Output is correct
61 Correct 531 ms 39520 KB Output is correct
62 Correct 484 ms 39888 KB Output is correct
63 Correct 504 ms 40196 KB Output is correct
64 Correct 601 ms 39420 KB Output is correct
65 Correct 590 ms 39328 KB Output is correct
66 Correct 617 ms 39344 KB Output is correct
67 Correct 628 ms 39556 KB Output is correct
68 Correct 576 ms 39600 KB Output is correct
69 Correct 551 ms 39720 KB Output is correct
70 Correct 589 ms 39720 KB Output is correct
71 Correct 12 ms 24020 KB Output is correct
72 Correct 20 ms 24304 KB Output is correct
73 Correct 20 ms 24404 KB Output is correct
74 Correct 21 ms 24376 KB Output is correct
75 Correct 20 ms 24384 KB Output is correct
76 Correct 21 ms 24404 KB Output is correct
77 Correct 22 ms 24344 KB Output is correct
78 Correct 22 ms 24404 KB Output is correct
79 Correct 34 ms 24368 KB Output is correct
80 Correct 567 ms 39784 KB Output is correct
81 Correct 613 ms 39632 KB Output is correct
82 Correct 614 ms 39596 KB Output is correct
83 Correct 607 ms 39536 KB Output is correct
84 Correct 19 ms 24316 KB Output is correct
85 Correct 21 ms 24152 KB Output is correct
86 Correct 19 ms 24232 KB Output is correct
87 Correct 20 ms 24236 KB Output is correct
88 Correct 22 ms 24276 KB Output is correct
89 Correct 23 ms 24364 KB Output is correct
90 Correct 24 ms 24332 KB Output is correct
91 Correct 26 ms 24344 KB Output is correct
92 Correct 22 ms 24276 KB Output is correct
93 Correct 23 ms 24320 KB Output is correct
94 Correct 13 ms 24016 KB Output is correct
95 Correct 13 ms 24020 KB Output is correct
96 Correct 13 ms 24036 KB Output is correct
97 Correct 14 ms 23932 KB Output is correct
98 Correct 14 ms 24020 KB Output is correct
99 Correct 16 ms 24020 KB Output is correct
100 Correct 13 ms 23980 KB Output is correct
101 Correct 13 ms 24020 KB Output is correct
102 Correct 14 ms 24160 KB Output is correct
103 Correct 14 ms 24080 KB Output is correct
104 Correct 51 ms 25360 KB Output is correct
105 Correct 97 ms 26808 KB Output is correct
106 Correct 15 ms 23876 KB Output is correct
107 Correct 214 ms 29980 KB Output is correct
108 Correct 268 ms 31428 KB Output is correct
109 Correct 14 ms 23892 KB Output is correct
110 Correct 390 ms 34520 KB Output is correct
111 Correct 459 ms 35872 KB Output is correct
112 Correct 14 ms 24020 KB Output is correct
113 Correct 715 ms 38868 KB Output is correct
114 Incorrect 788 ms 39256 KB Output isn't correct
115 Halted 0 ms 0 KB -