답안 #541790

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
541790 2022-03-24T11:50:18 Z Sho10 꿈 (IOI13_dreaming) C++17
24 / 100
1000 ms 23588 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;
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++)
      |            ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 737 ms 21476 KB Output is correct
2 Correct 733 ms 21552 KB Output is correct
3 Correct 432 ms 14540 KB Output is correct
4 Correct 64 ms 5256 KB Output is correct
5 Correct 47 ms 4556 KB Output is correct
6 Correct 109 ms 6484 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 240 ms 10588 KB Output is correct
9 Correct 417 ms 12364 KB Output is correct
10 Correct 5 ms 2772 KB Output is correct
11 Correct 559 ms 16636 KB Output is correct
12 Correct 699 ms 18328 KB Output is correct
13 Correct 4 ms 2772 KB Output is correct
# 결과 실행 시간 메모리 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 3 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 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
# 결과 실행 시간 메모리 Grader output
1 Correct 737 ms 21476 KB Output is correct
2 Correct 733 ms 21552 KB Output is correct
3 Correct 432 ms 14540 KB Output is correct
4 Correct 64 ms 5256 KB Output is correct
5 Correct 47 ms 4556 KB Output is correct
6 Correct 109 ms 6484 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 240 ms 10588 KB Output is correct
9 Correct 417 ms 12364 KB Output is correct
10 Correct 5 ms 2772 KB Output is correct
11 Correct 559 ms 16636 KB Output is correct
12 Correct 699 ms 18328 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 3 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 2 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 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 783 ms 21476 KB Output is correct
40 Correct 702 ms 21456 KB Output is correct
41 Correct 460 ms 14656 KB Output is correct
42 Correct 66 ms 5372 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 2 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 3 ms 2644 KB Output is correct
55 Correct 2 ms 2644 KB Output is correct
56 Correct 3 ms 2644 KB Output is correct
57 Correct 884 ms 23028 KB Output is correct
58 Correct 846 ms 23248 KB Output is correct
59 Correct 902 ms 22944 KB Output is correct
60 Correct 895 ms 23084 KB Output is correct
61 Correct 868 ms 22920 KB Output is correct
62 Correct 878 ms 23160 KB Output is correct
63 Correct 900 ms 23588 KB Output is correct
64 Correct 826 ms 22800 KB Output is correct
65 Correct 925 ms 22760 KB Output is correct
66 Correct 939 ms 22880 KB Output is correct
67 Correct 957 ms 22944 KB Output is correct
68 Correct 946 ms 22980 KB Output is correct
69 Correct 904 ms 23044 KB Output is correct
70 Correct 872 ms 22996 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 15 ms 3328 KB Output is correct
73 Correct 19 ms 3284 KB Output is correct
74 Correct 13 ms 3284 KB Output is correct
75 Correct 14 ms 3220 KB Output is correct
76 Correct 13 ms 3220 KB Output is correct
77 Correct 13 ms 3224 KB Output is correct
78 Correct 18 ms 3288 KB Output is correct
79 Correct 16 ms 3208 KB Output is correct
80 Execution timed out 1037 ms 23124 KB Time limit exceeded
81 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 435 ms 22436 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 3 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 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 5 ms 2772 KB Output is correct
27 Correct 11 ms 3028 KB Output is correct
28 Correct 13 ms 3232 KB Output is correct
29 Incorrect 6 ms 2820 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 737 ms 21476 KB Output is correct
2 Correct 733 ms 21552 KB Output is correct
3 Correct 432 ms 14540 KB Output is correct
4 Correct 64 ms 5256 KB Output is correct
5 Correct 47 ms 4556 KB Output is correct
6 Correct 109 ms 6484 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 240 ms 10588 KB Output is correct
9 Correct 417 ms 12364 KB Output is correct
10 Correct 5 ms 2772 KB Output is correct
11 Correct 559 ms 16636 KB Output is correct
12 Correct 699 ms 18328 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 3 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 2 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 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 783 ms 21476 KB Output is correct
40 Correct 702 ms 21456 KB Output is correct
41 Correct 460 ms 14656 KB Output is correct
42 Correct 66 ms 5372 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 2 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 3 ms 2644 KB Output is correct
55 Correct 2 ms 2644 KB Output is correct
56 Correct 3 ms 2644 KB Output is correct
57 Correct 884 ms 23028 KB Output is correct
58 Correct 846 ms 23248 KB Output is correct
59 Correct 902 ms 22944 KB Output is correct
60 Correct 895 ms 23084 KB Output is correct
61 Correct 868 ms 22920 KB Output is correct
62 Correct 878 ms 23160 KB Output is correct
63 Correct 900 ms 23588 KB Output is correct
64 Correct 826 ms 22800 KB Output is correct
65 Correct 925 ms 22760 KB Output is correct
66 Correct 939 ms 22880 KB Output is correct
67 Correct 957 ms 22944 KB Output is correct
68 Correct 946 ms 22980 KB Output is correct
69 Correct 904 ms 23044 KB Output is correct
70 Correct 872 ms 22996 KB Output is correct
71 Correct 2 ms 2644 KB Output is correct
72 Correct 15 ms 3328 KB Output is correct
73 Correct 19 ms 3284 KB Output is correct
74 Correct 13 ms 3284 KB Output is correct
75 Correct 14 ms 3220 KB Output is correct
76 Correct 13 ms 3220 KB Output is correct
77 Correct 13 ms 3224 KB Output is correct
78 Correct 18 ms 3288 KB Output is correct
79 Correct 16 ms 3208 KB Output is correct
80 Execution timed out 1037 ms 23124 KB Time limit exceeded
81 Halted 0 ms 0 KB -