Submission #541787

# Submission time Handle Problem Language Result Execution time Memory
541787 2022-03-24T11:46:55 Z Sho10 Dreaming (IOI13_dreaming) C++17
24 / 100
1000 ms 25020 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;
ll mxN=1e5+5;
vector<pair<ll,ll>>g[100005];
vector<ll>comp;
map<ll,ll>viz;
ll bg;
map<ll,ll> bfs(ll node){
map<ll,ll>dist;
dist[node]=0;
queue<ll>q;
q.push(node);
vector<bool>check(mxN,false);
check[node]=1;
ll mx=0;
while(!q.empty()){
    ll x=q.front();
    q.pop();
    comp.pb(x);
    viz[x]=1;
    for(auto it : g[x]){
        if(check[it.f]==0){
            dist[it.f]=dist[x]+it.s;
            q.push(it.f);
            check[it.f]=1;
            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 715 ms 21480 KB Output is correct
2 Correct 746 ms 21400 KB Output is correct
3 Correct 423 ms 14656 KB Output is correct
4 Correct 65 ms 5376 KB Output is correct
5 Correct 45 ms 4616 KB Output is correct
6 Correct 109 ms 6616 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 239 ms 11100 KB Output is correct
9 Correct 344 ms 13200 KB Output is correct
10 Correct 3 ms 2772 KB Output is correct
11 Correct 571 ms 17744 KB Output is correct
12 Correct 679 ms 19368 KB Output is correct
13 Correct 5 ms 2900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2660 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 3 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2660 KB Output is correct
24 Correct 2 ms 2660 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 715 ms 21480 KB Output is correct
2 Correct 746 ms 21400 KB Output is correct
3 Correct 423 ms 14656 KB Output is correct
4 Correct 65 ms 5376 KB Output is correct
5 Correct 45 ms 4616 KB Output is correct
6 Correct 109 ms 6616 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 239 ms 11100 KB Output is correct
9 Correct 344 ms 13200 KB Output is correct
10 Correct 3 ms 2772 KB Output is correct
11 Correct 571 ms 17744 KB Output is correct
12 Correct 679 ms 19368 KB Output is correct
13 Correct 5 ms 2900 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2660 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 3 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2644 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2660 KB Output is correct
37 Correct 2 ms 2660 KB Output is correct
38 Correct 2 ms 2644 KB Output is correct
39 Correct 748 ms 22716 KB Output is correct
40 Correct 731 ms 22688 KB Output is correct
41 Correct 403 ms 15508 KB Output is correct
42 Correct 64 ms 5576 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 2 ms 2664 KB Output is correct
45 Correct 2 ms 2664 KB Output is correct
46 Correct 2 ms 2644 KB Output is correct
47 Correct 2 ms 2644 KB Output is correct
48 Correct 2 ms 2656 KB Output is correct
49 Correct 2 ms 2656 KB Output is correct
50 Correct 2 ms 2644 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 2 ms 2660 KB Output is correct
53 Correct 2 ms 2644 KB Output is correct
54 Correct 2 ms 2644 KB Output is correct
55 Correct 2 ms 2644 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 823 ms 24360 KB Output is correct
58 Correct 771 ms 24544 KB Output is correct
59 Correct 788 ms 24292 KB Output is correct
60 Correct 819 ms 24488 KB Output is correct
61 Correct 827 ms 24432 KB Output is correct
62 Correct 797 ms 24760 KB Output is correct
63 Correct 828 ms 25020 KB Output is correct
64 Correct 864 ms 24064 KB Output is correct
65 Correct 850 ms 24520 KB Output is correct
66 Correct 820 ms 24372 KB Output is correct
67 Correct 806 ms 24276 KB Output is correct
68 Correct 790 ms 24340 KB Output is correct
69 Correct 783 ms 24736 KB Output is correct
70 Correct 785 ms 24844 KB Output is correct
71 Correct 1 ms 2644 KB Output is correct
72 Correct 13 ms 3224 KB Output is correct
73 Correct 12 ms 3308 KB Output is correct
74 Correct 12 ms 3340 KB Output is correct
75 Correct 14 ms 3312 KB Output is correct
76 Correct 13 ms 3312 KB Output is correct
77 Correct 12 ms 3276 KB Output is correct
78 Correct 12 ms 3308 KB Output is correct
79 Correct 12 ms 3284 KB Output is correct
80 Correct 781 ms 24520 KB Output is correct
81 Correct 787 ms 24392 KB Output is correct
82 Correct 836 ms 24444 KB Output is correct
83 Correct 846 ms 25020 KB Output is correct
84 Correct 9 ms 3156 KB Output is correct
85 Correct 9 ms 3084 KB Output is correct
86 Correct 9 ms 3200 KB Output is correct
87 Correct 12 ms 3156 KB Output is correct
88 Correct 10 ms 3240 KB Output is correct
89 Correct 11 ms 3156 KB Output is correct
90 Correct 11 ms 3156 KB Output is correct
91 Correct 12 ms 3308 KB Output is correct
92 Correct 11 ms 3180 KB Output is correct
93 Correct 11 ms 3184 KB Output is correct
94 Correct 2 ms 2644 KB Output is correct
95 Correct 2 ms 2644 KB Output is correct
96 Correct 2 ms 2660 KB Output is correct
97 Correct 2 ms 2644 KB Output is correct
98 Correct 2 ms 2644 KB Output is correct
99 Correct 2 ms 2644 KB Output is correct
100 Correct 2 ms 2644 KB Output is correct
101 Correct 2 ms 2660 KB Output is correct
102 Correct 2 ms 2656 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 48 ms 4684 KB Output is correct
105 Correct 118 ms 6872 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 241 ms 11016 KB Output is correct
108 Correct 309 ms 13140 KB Output is correct
109 Correct 3 ms 2772 KB Output is correct
110 Correct 493 ms 17692 KB Output is correct
111 Correct 637 ms 19416 KB Output is correct
112 Correct 5 ms 2772 KB Output is correct
113 Execution timed out 1049 ms 24864 KB Time limit exceeded
114 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 415 ms 22344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 2 ms 2644 KB Output is correct
3 Correct 2 ms 2644 KB Output is correct
4 Correct 2 ms 2644 KB Output is correct
5 Correct 2 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 2 ms 2644 KB Output is correct
9 Correct 2 ms 2644 KB Output is correct
10 Correct 2 ms 2660 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 2 ms 2644 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 3 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2660 KB Output is correct
24 Correct 2 ms 2660 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 4 ms 2900 KB Output is correct
27 Correct 12 ms 3028 KB Output is correct
28 Correct 11 ms 3284 KB Output is correct
29 Incorrect 5 ms 2900 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 715 ms 21480 KB Output is correct
2 Correct 746 ms 21400 KB Output is correct
3 Correct 423 ms 14656 KB Output is correct
4 Correct 65 ms 5376 KB Output is correct
5 Correct 45 ms 4616 KB Output is correct
6 Correct 109 ms 6616 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 239 ms 11100 KB Output is correct
9 Correct 344 ms 13200 KB Output is correct
10 Correct 3 ms 2772 KB Output is correct
11 Correct 571 ms 17744 KB Output is correct
12 Correct 679 ms 19368 KB Output is correct
13 Correct 5 ms 2900 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 2 ms 2644 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2644 KB Output is correct
18 Correct 2 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 2 ms 2660 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 2 ms 2644 KB Output is correct
27 Correct 2 ms 2644 KB Output is correct
28 Correct 2 ms 2644 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 3 ms 2644 KB Output is correct
31 Correct 2 ms 2644 KB Output is correct
32 Correct 2 ms 2644 KB Output is correct
33 Correct 2 ms 2644 KB Output is correct
34 Correct 2 ms 2644 KB Output is correct
35 Correct 2 ms 2644 KB Output is correct
36 Correct 2 ms 2660 KB Output is correct
37 Correct 2 ms 2660 KB Output is correct
38 Correct 2 ms 2644 KB Output is correct
39 Correct 748 ms 22716 KB Output is correct
40 Correct 731 ms 22688 KB Output is correct
41 Correct 403 ms 15508 KB Output is correct
42 Correct 64 ms 5576 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 2 ms 2664 KB Output is correct
45 Correct 2 ms 2664 KB Output is correct
46 Correct 2 ms 2644 KB Output is correct
47 Correct 2 ms 2644 KB Output is correct
48 Correct 2 ms 2656 KB Output is correct
49 Correct 2 ms 2656 KB Output is correct
50 Correct 2 ms 2644 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 2 ms 2660 KB Output is correct
53 Correct 2 ms 2644 KB Output is correct
54 Correct 2 ms 2644 KB Output is correct
55 Correct 2 ms 2644 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 823 ms 24360 KB Output is correct
58 Correct 771 ms 24544 KB Output is correct
59 Correct 788 ms 24292 KB Output is correct
60 Correct 819 ms 24488 KB Output is correct
61 Correct 827 ms 24432 KB Output is correct
62 Correct 797 ms 24760 KB Output is correct
63 Correct 828 ms 25020 KB Output is correct
64 Correct 864 ms 24064 KB Output is correct
65 Correct 850 ms 24520 KB Output is correct
66 Correct 820 ms 24372 KB Output is correct
67 Correct 806 ms 24276 KB Output is correct
68 Correct 790 ms 24340 KB Output is correct
69 Correct 783 ms 24736 KB Output is correct
70 Correct 785 ms 24844 KB Output is correct
71 Correct 1 ms 2644 KB Output is correct
72 Correct 13 ms 3224 KB Output is correct
73 Correct 12 ms 3308 KB Output is correct
74 Correct 12 ms 3340 KB Output is correct
75 Correct 14 ms 3312 KB Output is correct
76 Correct 13 ms 3312 KB Output is correct
77 Correct 12 ms 3276 KB Output is correct
78 Correct 12 ms 3308 KB Output is correct
79 Correct 12 ms 3284 KB Output is correct
80 Correct 781 ms 24520 KB Output is correct
81 Correct 787 ms 24392 KB Output is correct
82 Correct 836 ms 24444 KB Output is correct
83 Correct 846 ms 25020 KB Output is correct
84 Correct 9 ms 3156 KB Output is correct
85 Correct 9 ms 3084 KB Output is correct
86 Correct 9 ms 3200 KB Output is correct
87 Correct 12 ms 3156 KB Output is correct
88 Correct 10 ms 3240 KB Output is correct
89 Correct 11 ms 3156 KB Output is correct
90 Correct 11 ms 3156 KB Output is correct
91 Correct 12 ms 3308 KB Output is correct
92 Correct 11 ms 3180 KB Output is correct
93 Correct 11 ms 3184 KB Output is correct
94 Correct 2 ms 2644 KB Output is correct
95 Correct 2 ms 2644 KB Output is correct
96 Correct 2 ms 2660 KB Output is correct
97 Correct 2 ms 2644 KB Output is correct
98 Correct 2 ms 2644 KB Output is correct
99 Correct 2 ms 2644 KB Output is correct
100 Correct 2 ms 2644 KB Output is correct
101 Correct 2 ms 2660 KB Output is correct
102 Correct 2 ms 2656 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 48 ms 4684 KB Output is correct
105 Correct 118 ms 6872 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 241 ms 11016 KB Output is correct
108 Correct 309 ms 13140 KB Output is correct
109 Correct 3 ms 2772 KB Output is correct
110 Correct 493 ms 17692 KB Output is correct
111 Correct 637 ms 19416 KB Output is correct
112 Correct 5 ms 2772 KB Output is correct
113 Execution timed out 1049 ms 24864 KB Time limit exceeded
114 Halted 0 ms 0 KB -