Submission #541792

# Submission time Handle Problem Language Result Execution time Memory
541792 2022-03-24T11:52:02 Z Sho10 Dreaming (IOI13_dreaming) C++17
47 / 100
576 ms 19008 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=100005;
bool viz[mxN];
vector<pair<ll,ll>>g[100005];
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 446 ms 17288 KB Output is correct
2 Correct 434 ms 17256 KB Output is correct
3 Correct 269 ms 11860 KB Output is correct
4 Correct 49 ms 4760 KB Output is correct
5 Correct 35 ms 4172 KB Output is correct
6 Correct 77 ms 5612 KB Output is correct
7 Correct 2 ms 2728 KB Output is correct
8 Correct 155 ms 8684 KB Output is correct
9 Correct 215 ms 10104 KB Output is correct
10 Correct 3 ms 2772 KB Output is correct
11 Correct 316 ms 13364 KB Output is correct
12 Correct 393 ms 14688 KB Output is correct
13 Correct 4 ms 2772 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 2644 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 1 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 1 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 446 ms 17288 KB Output is correct
2 Correct 434 ms 17256 KB Output is correct
3 Correct 269 ms 11860 KB Output is correct
4 Correct 49 ms 4760 KB Output is correct
5 Correct 35 ms 4172 KB Output is correct
6 Correct 77 ms 5612 KB Output is correct
7 Correct 2 ms 2728 KB Output is correct
8 Correct 155 ms 8684 KB Output is correct
9 Correct 215 ms 10104 KB Output is correct
10 Correct 3 ms 2772 KB Output is correct
11 Correct 316 ms 13364 KB Output is correct
12 Correct 393 ms 14688 KB Output is correct
13 Correct 4 ms 2772 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 2644 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 1 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 1 ms 2644 KB Output is correct
36 Correct 2 ms 2644 KB Output is correct
37 Correct 2 ms 2644 KB Output is correct
38 Correct 2 ms 2644 KB Output is correct
39 Correct 450 ms 17380 KB Output is correct
40 Correct 442 ms 17332 KB Output is correct
41 Correct 265 ms 11924 KB Output is correct
42 Correct 47 ms 4688 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 2 ms 2644 KB Output is correct
45 Correct 2 ms 2644 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 2644 KB Output is correct
49 Correct 1 ms 2644 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 2644 KB Output is correct
53 Correct 2 ms 2644 KB Output is correct
54 Correct 2 ms 2644 KB Output is correct
55 Correct 1 ms 2644 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 533 ms 18572 KB Output is correct
58 Correct 495 ms 18696 KB Output is correct
59 Correct 509 ms 18308 KB Output is correct
60 Correct 483 ms 18484 KB Output is correct
61 Correct 493 ms 18328 KB Output is correct
62 Correct 480 ms 18604 KB Output is correct
63 Correct 496 ms 19008 KB Output is correct
64 Correct 497 ms 18160 KB Output is correct
65 Correct 531 ms 18096 KB Output is correct
66 Correct 505 ms 18136 KB Output is correct
67 Correct 509 ms 18288 KB Output is correct
68 Correct 497 ms 18248 KB Output is correct
69 Correct 469 ms 18472 KB Output is correct
70 Correct 487 ms 18648 KB Output is correct
71 Correct 1 ms 2644 KB Output is correct
72 Correct 9 ms 3156 KB Output is correct
73 Correct 10 ms 3156 KB Output is correct
74 Correct 9 ms 3156 KB Output is correct
75 Correct 10 ms 3160 KB Output is correct
76 Correct 10 ms 3156 KB Output is correct
77 Correct 10 ms 3104 KB Output is correct
78 Correct 10 ms 3156 KB Output is correct
79 Correct 10 ms 3156 KB Output is correct
80 Correct 477 ms 18468 KB Output is correct
81 Correct 507 ms 18340 KB Output is correct
82 Correct 496 ms 18296 KB Output is correct
83 Correct 556 ms 18896 KB Output is correct
84 Correct 8 ms 3028 KB Output is correct
85 Correct 7 ms 2968 KB Output is correct
86 Correct 10 ms 3156 KB Output is correct
87 Correct 9 ms 3028 KB Output is correct
88 Correct 9 ms 3084 KB Output is correct
89 Correct 8 ms 3028 KB Output is correct
90 Correct 9 ms 3028 KB Output is correct
91 Correct 10 ms 3156 KB Output is correct
92 Correct 9 ms 3028 KB Output is correct
93 Correct 10 ms 3036 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 2644 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 2644 KB Output is correct
102 Correct 2 ms 2644 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 34 ms 4164 KB Output is correct
105 Correct 82 ms 5580 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 159 ms 8644 KB Output is correct
108 Correct 265 ms 10128 KB Output is correct
109 Correct 3 ms 2772 KB Output is correct
110 Correct 332 ms 13272 KB Output is correct
111 Correct 385 ms 14780 KB Output is correct
112 Correct 4 ms 2772 KB Output is correct
113 Correct 576 ms 18760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 240 ms 18108 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 2644 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 1 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 1 ms 2644 KB Output is correct
23 Correct 2 ms 2644 KB Output is correct
24 Correct 2 ms 2644 KB Output is correct
25 Correct 2 ms 2644 KB Output is correct
26 Correct 3 ms 2772 KB Output is correct
27 Correct 6 ms 2900 KB Output is correct
28 Correct 8 ms 3112 KB Output is correct
29 Incorrect 3 ms 2772 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 446 ms 17288 KB Output is correct
2 Correct 434 ms 17256 KB Output is correct
3 Correct 269 ms 11860 KB Output is correct
4 Correct 49 ms 4760 KB Output is correct
5 Correct 35 ms 4172 KB Output is correct
6 Correct 77 ms 5612 KB Output is correct
7 Correct 2 ms 2728 KB Output is correct
8 Correct 155 ms 8684 KB Output is correct
9 Correct 215 ms 10104 KB Output is correct
10 Correct 3 ms 2772 KB Output is correct
11 Correct 316 ms 13364 KB Output is correct
12 Correct 393 ms 14688 KB Output is correct
13 Correct 4 ms 2772 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 2644 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 1 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 1 ms 2644 KB Output is correct
36 Correct 2 ms 2644 KB Output is correct
37 Correct 2 ms 2644 KB Output is correct
38 Correct 2 ms 2644 KB Output is correct
39 Correct 450 ms 17380 KB Output is correct
40 Correct 442 ms 17332 KB Output is correct
41 Correct 265 ms 11924 KB Output is correct
42 Correct 47 ms 4688 KB Output is correct
43 Correct 2 ms 2644 KB Output is correct
44 Correct 2 ms 2644 KB Output is correct
45 Correct 2 ms 2644 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 2644 KB Output is correct
49 Correct 1 ms 2644 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 2644 KB Output is correct
53 Correct 2 ms 2644 KB Output is correct
54 Correct 2 ms 2644 KB Output is correct
55 Correct 1 ms 2644 KB Output is correct
56 Correct 2 ms 2644 KB Output is correct
57 Correct 533 ms 18572 KB Output is correct
58 Correct 495 ms 18696 KB Output is correct
59 Correct 509 ms 18308 KB Output is correct
60 Correct 483 ms 18484 KB Output is correct
61 Correct 493 ms 18328 KB Output is correct
62 Correct 480 ms 18604 KB Output is correct
63 Correct 496 ms 19008 KB Output is correct
64 Correct 497 ms 18160 KB Output is correct
65 Correct 531 ms 18096 KB Output is correct
66 Correct 505 ms 18136 KB Output is correct
67 Correct 509 ms 18288 KB Output is correct
68 Correct 497 ms 18248 KB Output is correct
69 Correct 469 ms 18472 KB Output is correct
70 Correct 487 ms 18648 KB Output is correct
71 Correct 1 ms 2644 KB Output is correct
72 Correct 9 ms 3156 KB Output is correct
73 Correct 10 ms 3156 KB Output is correct
74 Correct 9 ms 3156 KB Output is correct
75 Correct 10 ms 3160 KB Output is correct
76 Correct 10 ms 3156 KB Output is correct
77 Correct 10 ms 3104 KB Output is correct
78 Correct 10 ms 3156 KB Output is correct
79 Correct 10 ms 3156 KB Output is correct
80 Correct 477 ms 18468 KB Output is correct
81 Correct 507 ms 18340 KB Output is correct
82 Correct 496 ms 18296 KB Output is correct
83 Correct 556 ms 18896 KB Output is correct
84 Correct 8 ms 3028 KB Output is correct
85 Correct 7 ms 2968 KB Output is correct
86 Correct 10 ms 3156 KB Output is correct
87 Correct 9 ms 3028 KB Output is correct
88 Correct 9 ms 3084 KB Output is correct
89 Correct 8 ms 3028 KB Output is correct
90 Correct 9 ms 3028 KB Output is correct
91 Correct 10 ms 3156 KB Output is correct
92 Correct 9 ms 3028 KB Output is correct
93 Correct 10 ms 3036 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 2644 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 2644 KB Output is correct
102 Correct 2 ms 2644 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 34 ms 4164 KB Output is correct
105 Correct 82 ms 5580 KB Output is correct
106 Correct 2 ms 2644 KB Output is correct
107 Correct 159 ms 8644 KB Output is correct
108 Correct 265 ms 10128 KB Output is correct
109 Correct 3 ms 2772 KB Output is correct
110 Correct 332 ms 13272 KB Output is correct
111 Correct 385 ms 14780 KB Output is correct
112 Correct 4 ms 2772 KB Output is correct
113 Correct 576 ms 18760 KB Output is correct
114 Incorrect 240 ms 18108 KB Output isn't correct
115 Halted 0 ms 0 KB -