# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
315520 | 2020-10-23T02:59:23 Z | tasfiq4 | 꿈 (IOI13_dreaming) | C++14 | 128 ms | 17528 KB |
#include "dreaming.h" #include <bits/stdc++.h> using namespace std; typedef pair<int,int > pii; typedef long long int lld; #define pi acos(-1) #define fr(i,m,n) for(i=m;i<n;i++) #define fu(i,m,n) for(i=m;i>=n;i--) #define vec vector<int> #define pb push_back #define pp pop_back() #define ft first #define sd second #define all(v) v.begin(),v.end() #define mom(ara) memset(ara,0,sizeof(ara)); #define m1m(ara) memset(ara,-1,sizeof(ara)); #define endl "\n" #define eps 1.19209e-07 vector<pii> adj[100010]; int visited[100010]; int mx[100010]; void get_dm(int u,int p) { visited[u]=1; mx[u]=0; for(auto v:adj[u]) { if(v.ft==p) continue; get_dm(v.ft,u); mx[u]=max(mx[u],mx[v.ft]+v.sd); } } pii func(int u,int p,int d) { int m=d,m2=0,n=p,l=0; for(auto v:adj[u]) { if(v.ft==p) continue; if(mx[v.ft]+v.sd>m) { m2=m; m=mx[v.ft]+v.sd; n=v.ft; l=v.sd; } else if(mx[v.ft]+v.sd>m2) m2=mx[v.ft]+v.sd; } if(m2+l<m && n!=p) return func(n,u,m2+l); return {u,m}; } struct cmp { bool operator()(const pair<int,int> &a,const pair<int,int> &b) const{ return a.sd>b.sd; } }; pair<int, int> bfs(int n, int s) { vector<int> dis(n+1, -1); priority_queue<pii,vector<pii>,cmp> q; q.push({s,0}); dis[s] = 0; int last = n; while (q.size()) { int u = q.top().ft; q.pop(); for (auto v: adj[u]) if (dis[v.ft] == -1) { dis[v.ft] = dis[u] + v.sd; if(dis[v.ft]>dis[last]) last=v.ft; q.push({v.ft,v.sd}); } } return {last, dis[last]}; } int travelTime(int N, int M, int L, int A[], int B[], int T[]) { int i,j,a,b,c,x,y,z,n,m,w,k,t; priority_queue<pii,vector<pii>,cmp> h; n=N;m=M;k=L; fr(i,0,m) { a=A[i];b=B[i];w=T[i]; adj[a].pb({b,w}); adj[b].pb({a,w}); } fr(i,0,n) { if(visited[i]) continue; get_dm(i,-1); h.push(func(i,-1,0)); } while(h.size()!=1) { pii u=h.top(); h.pop(); pii v=h.top(); h.pop(); adj[u.ft].pb({v.ft,k}); adj[v.ft].pb({u.ft,k}); h.push({v.ft,max(u.sd+k,v.sd)}); } return bfs(n, bfs(n, 0).first).second; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 12944 KB | Output is correct |
2 | Correct | 66 ms | 12568 KB | Output is correct |
3 | Correct | 47 ms | 11008 KB | Output is correct |
4 | Correct | 10 ms | 4224 KB | Output is correct |
5 | Correct | 8 ms | 3584 KB | Output is correct |
6 | Correct | 17 ms | 4984 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 32 ms | 6904 KB | Output is correct |
9 | Correct | 48 ms | 9208 KB | Output is correct |
10 | Correct | 2 ms | 2816 KB | Output is correct |
11 | Correct | 65 ms | 10232 KB | Output is correct |
12 | Correct | 82 ms | 11612 KB | Output is correct |
13 | Correct | 3 ms | 2816 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 12944 KB | Output is correct |
2 | Correct | 66 ms | 12568 KB | Output is correct |
3 | Correct | 47 ms | 11008 KB | Output is correct |
4 | Correct | 10 ms | 4224 KB | Output is correct |
5 | Correct | 8 ms | 3584 KB | Output is correct |
6 | Correct | 17 ms | 4984 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 32 ms | 6904 KB | Output is correct |
9 | Correct | 48 ms | 9208 KB | Output is correct |
10 | Correct | 2 ms | 2816 KB | Output is correct |
11 | Correct | 65 ms | 10232 KB | Output is correct |
12 | Correct | 82 ms | 11612 KB | Output is correct |
13 | Correct | 3 ms | 2816 KB | Output is correct |
14 | Correct | 2 ms | 2688 KB | Output is correct |
15 | Correct | 2 ms | 2688 KB | Output is correct |
16 | Correct | 2 ms | 2688 KB | Output is correct |
17 | Correct | 2 ms | 2688 KB | Output is correct |
18 | Correct | 2 ms | 2688 KB | Output is correct |
19 | Correct | 2 ms | 2688 KB | Output is correct |
20 | Correct | 2 ms | 2688 KB | Output is correct |
21 | Correct | 2 ms | 2688 KB | Output is correct |
22 | Correct | 2 ms | 2720 KB | Output is correct |
23 | Correct | 2 ms | 2688 KB | Output is correct |
24 | Correct | 2 ms | 2688 KB | Output is correct |
25 | Correct | 2 ms | 2688 KB | Output is correct |
26 | Correct | 2 ms | 2688 KB | Output is correct |
27 | Correct | 2 ms | 2688 KB | Output is correct |
28 | Correct | 2 ms | 2688 KB | Output is correct |
29 | Correct | 2 ms | 2720 KB | Output is correct |
30 | Correct | 2 ms | 2688 KB | Output is correct |
31 | Correct | 2 ms | 2688 KB | Output is correct |
32 | Correct | 2 ms | 2688 KB | Output is correct |
33 | Correct | 2 ms | 2688 KB | Output is correct |
34 | Correct | 2 ms | 2688 KB | Output is correct |
35 | Correct | 2 ms | 2688 KB | Output is correct |
36 | Correct | 2 ms | 2688 KB | Output is correct |
37 | Correct | 2 ms | 2816 KB | Output is correct |
38 | Correct | 2 ms | 2688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 12944 KB | Output is correct |
2 | Correct | 66 ms | 12568 KB | Output is correct |
3 | Correct | 47 ms | 11008 KB | Output is correct |
4 | Correct | 10 ms | 4224 KB | Output is correct |
5 | Correct | 8 ms | 3584 KB | Output is correct |
6 | Correct | 17 ms | 4984 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 32 ms | 6904 KB | Output is correct |
9 | Correct | 48 ms | 9208 KB | Output is correct |
10 | Correct | 2 ms | 2816 KB | Output is correct |
11 | Correct | 65 ms | 10232 KB | Output is correct |
12 | Correct | 82 ms | 11612 KB | Output is correct |
13 | Correct | 3 ms | 2816 KB | Output is correct |
14 | Correct | 2 ms | 2688 KB | Output is correct |
15 | Correct | 2 ms | 2688 KB | Output is correct |
16 | Correct | 2 ms | 2688 KB | Output is correct |
17 | Correct | 2 ms | 2688 KB | Output is correct |
18 | Correct | 2 ms | 2688 KB | Output is correct |
19 | Correct | 2 ms | 2688 KB | Output is correct |
20 | Correct | 2 ms | 2688 KB | Output is correct |
21 | Correct | 2 ms | 2688 KB | Output is correct |
22 | Correct | 2 ms | 2720 KB | Output is correct |
23 | Correct | 2 ms | 2688 KB | Output is correct |
24 | Correct | 2 ms | 2688 KB | Output is correct |
25 | Correct | 2 ms | 2688 KB | Output is correct |
26 | Correct | 2 ms | 2688 KB | Output is correct |
27 | Correct | 2 ms | 2688 KB | Output is correct |
28 | Correct | 2 ms | 2688 KB | Output is correct |
29 | Correct | 2 ms | 2720 KB | Output is correct |
30 | Correct | 2 ms | 2688 KB | Output is correct |
31 | Correct | 2 ms | 2688 KB | Output is correct |
32 | Correct | 2 ms | 2688 KB | Output is correct |
33 | Correct | 2 ms | 2688 KB | Output is correct |
34 | Correct | 2 ms | 2688 KB | Output is correct |
35 | Correct | 2 ms | 2688 KB | Output is correct |
36 | Correct | 2 ms | 2688 KB | Output is correct |
37 | Correct | 2 ms | 2816 KB | Output is correct |
38 | Correct | 2 ms | 2688 KB | Output is correct |
39 | Correct | 66 ms | 12920 KB | Output is correct |
40 | Correct | 65 ms | 12564 KB | Output is correct |
41 | Correct | 44 ms | 11000 KB | Output is correct |
42 | Correct | 13 ms | 4256 KB | Output is correct |
43 | Correct | 2 ms | 2688 KB | Output is correct |
44 | Correct | 2 ms | 2688 KB | Output is correct |
45 | Correct | 2 ms | 2688 KB | Output is correct |
46 | Correct | 2 ms | 2688 KB | Output is correct |
47 | Correct | 2 ms | 2688 KB | Output is correct |
48 | Correct | 2 ms | 2688 KB | Output is correct |
49 | Correct | 2 ms | 2688 KB | Output is correct |
50 | Correct | 3 ms | 2688 KB | Output is correct |
51 | Correct | 2 ms | 2688 KB | Output is correct |
52 | Correct | 2 ms | 2688 KB | Output is correct |
53 | Correct | 2 ms | 2688 KB | Output is correct |
54 | Correct | 2 ms | 2688 KB | Output is correct |
55 | Correct | 2 ms | 2688 KB | Output is correct |
56 | Correct | 2 ms | 2688 KB | Output is correct |
57 | Correct | 116 ms | 10360 KB | Output is correct |
58 | Correct | 121 ms | 10360 KB | Output is correct |
59 | Correct | 119 ms | 10360 KB | Output is correct |
60 | Correct | 112 ms | 10292 KB | Output is correct |
61 | Correct | 120 ms | 10496 KB | Output is correct |
62 | Correct | 119 ms | 10360 KB | Output is correct |
63 | Correct | 111 ms | 10104 KB | Output is correct |
64 | Correct | 120 ms | 10104 KB | Output is correct |
65 | Correct | 126 ms | 10480 KB | Output is correct |
66 | Correct | 117 ms | 10488 KB | Output is correct |
67 | Correct | 124 ms | 10360 KB | Output is correct |
68 | Correct | 113 ms | 10360 KB | Output is correct |
69 | Correct | 118 ms | 10616 KB | Output is correct |
70 | Correct | 120 ms | 10616 KB | Output is correct |
71 | Correct | 2 ms | 2688 KB | Output is correct |
72 | Correct | 4 ms | 2944 KB | Output is correct |
73 | Correct | 4 ms | 2944 KB | Output is correct |
74 | Correct | 4 ms | 2944 KB | Output is correct |
75 | Correct | 4 ms | 2944 KB | Output is correct |
76 | Correct | 4 ms | 2944 KB | Output is correct |
77 | Correct | 4 ms | 2944 KB | Output is correct |
78 | Correct | 4 ms | 2944 KB | Output is correct |
79 | Correct | 4 ms | 2944 KB | Output is correct |
80 | Correct | 117 ms | 10236 KB | Output is correct |
81 | Correct | 125 ms | 10352 KB | Output is correct |
82 | Correct | 114 ms | 10488 KB | Output is correct |
83 | Correct | 117 ms | 10360 KB | Output is correct |
84 | Correct | 4 ms | 2816 KB | Output is correct |
85 | Correct | 3 ms | 2816 KB | Output is correct |
86 | Correct | 4 ms | 2816 KB | Output is correct |
87 | Correct | 4 ms | 2816 KB | Output is correct |
88 | Correct | 4 ms | 2944 KB | Output is correct |
89 | Correct | 4 ms | 2816 KB | Output is correct |
90 | Correct | 4 ms | 2816 KB | Output is correct |
91 | Correct | 4 ms | 2944 KB | Output is correct |
92 | Correct | 4 ms | 2944 KB | Output is correct |
93 | Correct | 4 ms | 2816 KB | Output is correct |
94 | Correct | 2 ms | 2688 KB | Output is correct |
95 | Correct | 2 ms | 2688 KB | Output is correct |
96 | Correct | 2 ms | 2816 KB | Output is correct |
97 | Correct | 2 ms | 2688 KB | Output is correct |
98 | Correct | 2 ms | 2688 KB | Output is correct |
99 | Correct | 2 ms | 2688 KB | Output is correct |
100 | Correct | 2 ms | 2688 KB | Output is correct |
101 | Correct | 2 ms | 2688 KB | Output is correct |
102 | Correct | 2 ms | 2688 KB | Output is correct |
103 | Correct | 2 ms | 2688 KB | Output is correct |
104 | Correct | 8 ms | 3584 KB | Output is correct |
105 | Correct | 16 ms | 4992 KB | Output is correct |
106 | Correct | 2 ms | 2688 KB | Output is correct |
107 | Correct | 33 ms | 7008 KB | Output is correct |
108 | Correct | 44 ms | 9212 KB | Output is correct |
109 | Correct | 2 ms | 2816 KB | Output is correct |
110 | Correct | 74 ms | 10232 KB | Output is correct |
111 | Correct | 83 ms | 11452 KB | Output is correct |
112 | Correct | 3 ms | 2816 KB | Output is correct |
113 | Correct | 128 ms | 17528 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 87 ms | 9588 KB | Output is correct |
2 | Incorrect | 89 ms | 9644 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 12944 KB | Output is correct |
2 | Correct | 66 ms | 12568 KB | Output is correct |
3 | Correct | 47 ms | 11008 KB | Output is correct |
4 | Correct | 10 ms | 4224 KB | Output is correct |
5 | Correct | 8 ms | 3584 KB | Output is correct |
6 | Correct | 17 ms | 4984 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 32 ms | 6904 KB | Output is correct |
9 | Correct | 48 ms | 9208 KB | Output is correct |
10 | Correct | 2 ms | 2816 KB | Output is correct |
11 | Correct | 65 ms | 10232 KB | Output is correct |
12 | Correct | 82 ms | 11612 KB | Output is correct |
13 | Correct | 3 ms | 2816 KB | Output is correct |
14 | Correct | 3 ms | 2688 KB | Output is correct |
15 | Correct | 3 ms | 2816 KB | Output is correct |
16 | Correct | 4 ms | 2944 KB | Output is correct |
17 | Incorrect | 3 ms | 2688 KB | Output isn't correct |
18 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 67 ms | 12944 KB | Output is correct |
2 | Correct | 66 ms | 12568 KB | Output is correct |
3 | Correct | 47 ms | 11008 KB | Output is correct |
4 | Correct | 10 ms | 4224 KB | Output is correct |
5 | Correct | 8 ms | 3584 KB | Output is correct |
6 | Correct | 17 ms | 4984 KB | Output is correct |
7 | Correct | 2 ms | 2688 KB | Output is correct |
8 | Correct | 32 ms | 6904 KB | Output is correct |
9 | Correct | 48 ms | 9208 KB | Output is correct |
10 | Correct | 2 ms | 2816 KB | Output is correct |
11 | Correct | 65 ms | 10232 KB | Output is correct |
12 | Correct | 82 ms | 11612 KB | Output is correct |
13 | Correct | 3 ms | 2816 KB | Output is correct |
14 | Correct | 2 ms | 2688 KB | Output is correct |
15 | Correct | 2 ms | 2688 KB | Output is correct |
16 | Correct | 2 ms | 2688 KB | Output is correct |
17 | Correct | 2 ms | 2688 KB | Output is correct |
18 | Correct | 2 ms | 2688 KB | Output is correct |
19 | Correct | 2 ms | 2688 KB | Output is correct |
20 | Correct | 2 ms | 2688 KB | Output is correct |
21 | Correct | 2 ms | 2688 KB | Output is correct |
22 | Correct | 2 ms | 2720 KB | Output is correct |
23 | Correct | 2 ms | 2688 KB | Output is correct |
24 | Correct | 2 ms | 2688 KB | Output is correct |
25 | Correct | 2 ms | 2688 KB | Output is correct |
26 | Correct | 2 ms | 2688 KB | Output is correct |
27 | Correct | 2 ms | 2688 KB | Output is correct |
28 | Correct | 2 ms | 2688 KB | Output is correct |
29 | Correct | 2 ms | 2720 KB | Output is correct |
30 | Correct | 2 ms | 2688 KB | Output is correct |
31 | Correct | 2 ms | 2688 KB | Output is correct |
32 | Correct | 2 ms | 2688 KB | Output is correct |
33 | Correct | 2 ms | 2688 KB | Output is correct |
34 | Correct | 2 ms | 2688 KB | Output is correct |
35 | Correct | 2 ms | 2688 KB | Output is correct |
36 | Correct | 2 ms | 2688 KB | Output is correct |
37 | Correct | 2 ms | 2816 KB | Output is correct |
38 | Correct | 2 ms | 2688 KB | Output is correct |
39 | Correct | 66 ms | 12920 KB | Output is correct |
40 | Correct | 65 ms | 12564 KB | Output is correct |
41 | Correct | 44 ms | 11000 KB | Output is correct |
42 | Correct | 13 ms | 4256 KB | Output is correct |
43 | Correct | 2 ms | 2688 KB | Output is correct |
44 | Correct | 2 ms | 2688 KB | Output is correct |
45 | Correct | 2 ms | 2688 KB | Output is correct |
46 | Correct | 2 ms | 2688 KB | Output is correct |
47 | Correct | 2 ms | 2688 KB | Output is correct |
48 | Correct | 2 ms | 2688 KB | Output is correct |
49 | Correct | 2 ms | 2688 KB | Output is correct |
50 | Correct | 3 ms | 2688 KB | Output is correct |
51 | Correct | 2 ms | 2688 KB | Output is correct |
52 | Correct | 2 ms | 2688 KB | Output is correct |
53 | Correct | 2 ms | 2688 KB | Output is correct |
54 | Correct | 2 ms | 2688 KB | Output is correct |
55 | Correct | 2 ms | 2688 KB | Output is correct |
56 | Correct | 2 ms | 2688 KB | Output is correct |
57 | Correct | 116 ms | 10360 KB | Output is correct |
58 | Correct | 121 ms | 10360 KB | Output is correct |
59 | Correct | 119 ms | 10360 KB | Output is correct |
60 | Correct | 112 ms | 10292 KB | Output is correct |
61 | Correct | 120 ms | 10496 KB | Output is correct |
62 | Correct | 119 ms | 10360 KB | Output is correct |
63 | Correct | 111 ms | 10104 KB | Output is correct |
64 | Correct | 120 ms | 10104 KB | Output is correct |
65 | Correct | 126 ms | 10480 KB | Output is correct |
66 | Correct | 117 ms | 10488 KB | Output is correct |
67 | Correct | 124 ms | 10360 KB | Output is correct |
68 | Correct | 113 ms | 10360 KB | Output is correct |
69 | Correct | 118 ms | 10616 KB | Output is correct |
70 | Correct | 120 ms | 10616 KB | Output is correct |
71 | Correct | 2 ms | 2688 KB | Output is correct |
72 | Correct | 4 ms | 2944 KB | Output is correct |
73 | Correct | 4 ms | 2944 KB | Output is correct |
74 | Correct | 4 ms | 2944 KB | Output is correct |
75 | Correct | 4 ms | 2944 KB | Output is correct |
76 | Correct | 4 ms | 2944 KB | Output is correct |
77 | Correct | 4 ms | 2944 KB | Output is correct |
78 | Correct | 4 ms | 2944 KB | Output is correct |
79 | Correct | 4 ms | 2944 KB | Output is correct |
80 | Correct | 117 ms | 10236 KB | Output is correct |
81 | Correct | 125 ms | 10352 KB | Output is correct |
82 | Correct | 114 ms | 10488 KB | Output is correct |
83 | Correct | 117 ms | 10360 KB | Output is correct |
84 | Correct | 4 ms | 2816 KB | Output is correct |
85 | Correct | 3 ms | 2816 KB | Output is correct |
86 | Correct | 4 ms | 2816 KB | Output is correct |
87 | Correct | 4 ms | 2816 KB | Output is correct |
88 | Correct | 4 ms | 2944 KB | Output is correct |
89 | Correct | 4 ms | 2816 KB | Output is correct |
90 | Correct | 4 ms | 2816 KB | Output is correct |
91 | Correct | 4 ms | 2944 KB | Output is correct |
92 | Correct | 4 ms | 2944 KB | Output is correct |
93 | Correct | 4 ms | 2816 KB | Output is correct |
94 | Correct | 2 ms | 2688 KB | Output is correct |
95 | Correct | 2 ms | 2688 KB | Output is correct |
96 | Correct | 2 ms | 2816 KB | Output is correct |
97 | Correct | 2 ms | 2688 KB | Output is correct |
98 | Correct | 2 ms | 2688 KB | Output is correct |
99 | Correct | 2 ms | 2688 KB | Output is correct |
100 | Correct | 2 ms | 2688 KB | Output is correct |
101 | Correct | 2 ms | 2688 KB | Output is correct |
102 | Correct | 2 ms | 2688 KB | Output is correct |
103 | Correct | 2 ms | 2688 KB | Output is correct |
104 | Correct | 8 ms | 3584 KB | Output is correct |
105 | Correct | 16 ms | 4992 KB | Output is correct |
106 | Correct | 2 ms | 2688 KB | Output is correct |
107 | Correct | 33 ms | 7008 KB | Output is correct |
108 | Correct | 44 ms | 9212 KB | Output is correct |
109 | Correct | 2 ms | 2816 KB | Output is correct |
110 | Correct | 74 ms | 10232 KB | Output is correct |
111 | Correct | 83 ms | 11452 KB | Output is correct |
112 | Correct | 3 ms | 2816 KB | Output is correct |
113 | Correct | 128 ms | 17528 KB | Output is correct |
114 | Correct | 87 ms | 9588 KB | Output is correct |
115 | Incorrect | 89 ms | 9644 KB | Output isn't correct |
116 | Halted | 0 ms | 0 KB | - |