답안 #282255

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
282255 2020-08-24T08:13:24 Z Ccucumber12 꿈 (IOI13_dreaming) C++17
47 / 100
170 ms 35576 KB
#include <bits/stdc++.h>
#include "dreaming.h"
using namespace std;

#define F first
#define S second
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define MP make_pair
#define PF push_front
#define PB push_back
#define POB pop_back
#define POF pop_front
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'
#define debug(...) cerr<<#__VA_ARGS__<<" = ";dbg(__VA_ARGS__);

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using Prior = priority_queue<T>;
template<typename T> using prior = priority_queue<T, vec<T>, greater<T>>;

const int INF = 1e9 + 1;
const ll LLINF = (ll)4*1e18;
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
const int xx[8] = {0,1,0,-1,1,1,-1,-1};
const int yy[8] = {1,0,-1,0,1,-1,-1,1};

template<typename T> void dbg(T x){ cerr<<x<<endl; }
template<typename T, typename ...A> void dbg(T x, A ...y){ cerr<<x<<", "; dbg(y...);}

template <typename T>
void printv(vec<T> v, char c = ' ') {
    bool spc = false;
    for(auto i:v)
        if(spc) cout << c << i;
        else    cout << i, spc = true;
    cout << endl;
}

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template<typename T> void amax(T &a, T b) {if(a < b) a = b;}
template<typename T> void amin(T &a, T b) {if(a > b) a = b;}
void pmod(ll &a, ll b) {a = (a+b)%MOD;}
void mmod(ll &a, ll b) {a = (a-b+MOD)%MOD;}
void tmod(ll &a, ll b) {a = (a*b)%MOD;}
void UNI(vec<int> &v) {sort(ALL(v)); v.rs(unique(ALL(v))-v.begin());}
int getint() {int ret; cin >> ret; return ret;}
ll POW(ll a, ll b) {ll res=1; do{if(b%2)tmod(res,a);tmod(a,a);}while(b>>=1); return res;}
ll getll() {ll ret; cin >> ret; return ret;}

const int MXN = 1000000;
const int N = MXN + 10;

vec<pii> g[N];
int vis[N], par[N], dep[N];
int dis, pt;

void dfs(int x, int p, int v){
	par[x] = p;
	dep[x] = v;
	vis[x] = true;
	for(auto i:g[x]) if(i.F != p)
		dfs(i.F, x, v + i.S);
	if(v > dis) pt = x;
	amax(dis, v);
}


int travelTime(int n, int m, int l, int a[], int b[], int t[]){
	rep(i, m){
		g[a[i]].EB(b[i], t[i]);
		g[b[i]].EB(a[i], t[i]);
	}
	
	vec<int> v;
	int self = 0;
	rep(i, n) if(!vis[i]){
		dis = pt = -1;
		dfs(i, -1, 0);
		
		dis = -1;
		dfs(pt, -1, 0);
		
		int idx = pt, len = INF;
		while(~idx) {
			amin(len, max(dep[idx], dis - dep[idx]));
			idx = par[idx];
		}
		v.EB(len);
		amax(self, dis);
	}
	
	sort(ALL(v), greater<int>());
	if(siz(v) == 1)
		return self;
	else
		return max(self, v[0] + v[1] + l); 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 34168 KB Output is correct
2 Correct 85 ms 34424 KB Output is correct
3 Correct 65 ms 30840 KB Output is correct
4 Correct 24 ms 25344 KB Output is correct
5 Correct 22 ms 24704 KB Output is correct
6 Correct 29 ms 26240 KB Output is correct
7 Correct 16 ms 23808 KB Output is correct
8 Correct 44 ms 27640 KB Output is correct
9 Correct 51 ms 29192 KB Output is correct
10 Correct 16 ms 23936 KB Output is correct
11 Correct 80 ms 30968 KB Output is correct
12 Correct 89 ms 32640 KB Output is correct
13 Correct 18 ms 23936 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 34168 KB Output is correct
2 Correct 85 ms 34424 KB Output is correct
3 Correct 65 ms 30840 KB Output is correct
4 Correct 24 ms 25344 KB Output is correct
5 Correct 22 ms 24704 KB Output is correct
6 Correct 29 ms 26240 KB Output is correct
7 Correct 16 ms 23808 KB Output is correct
8 Correct 44 ms 27640 KB Output is correct
9 Correct 51 ms 29192 KB Output is correct
10 Correct 16 ms 23936 KB Output is correct
11 Correct 80 ms 30968 KB Output is correct
12 Correct 89 ms 32640 KB Output is correct
13 Correct 18 ms 23936 KB Output is correct
14 Correct 16 ms 23808 KB Output is correct
15 Correct 16 ms 23808 KB Output is correct
16 Correct 16 ms 23808 KB Output is correct
17 Correct 16 ms 23808 KB Output is correct
18 Correct 16 ms 23808 KB Output is correct
19 Correct 16 ms 23808 KB Output is correct
20 Correct 16 ms 23808 KB Output is correct
21 Correct 16 ms 23808 KB Output is correct
22 Correct 17 ms 23808 KB Output is correct
23 Correct 16 ms 23808 KB Output is correct
24 Correct 18 ms 23936 KB Output is correct
25 Correct 16 ms 23808 KB Output is correct
26 Correct 16 ms 23808 KB Output is correct
27 Correct 16 ms 23808 KB Output is correct
28 Correct 18 ms 23936 KB Output is correct
29 Correct 16 ms 23808 KB Output is correct
30 Correct 16 ms 23900 KB Output is correct
31 Correct 16 ms 23936 KB Output is correct
32 Correct 16 ms 23808 KB Output is correct
33 Correct 16 ms 23808 KB Output is correct
34 Correct 16 ms 23808 KB Output is correct
35 Correct 16 ms 23808 KB Output is correct
36 Correct 16 ms 23808 KB Output is correct
37 Correct 17 ms 23936 KB Output is correct
38 Correct 18 ms 23808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 34168 KB Output is correct
2 Correct 85 ms 34424 KB Output is correct
3 Correct 65 ms 30840 KB Output is correct
4 Correct 24 ms 25344 KB Output is correct
5 Correct 22 ms 24704 KB Output is correct
6 Correct 29 ms 26240 KB Output is correct
7 Correct 16 ms 23808 KB Output is correct
8 Correct 44 ms 27640 KB Output is correct
9 Correct 51 ms 29192 KB Output is correct
10 Correct 16 ms 23936 KB Output is correct
11 Correct 80 ms 30968 KB Output is correct
12 Correct 89 ms 32640 KB Output is correct
13 Correct 18 ms 23936 KB Output is correct
14 Correct 16 ms 23808 KB Output is correct
15 Correct 16 ms 23808 KB Output is correct
16 Correct 16 ms 23808 KB Output is correct
17 Correct 16 ms 23808 KB Output is correct
18 Correct 16 ms 23808 KB Output is correct
19 Correct 16 ms 23808 KB Output is correct
20 Correct 16 ms 23808 KB Output is correct
21 Correct 16 ms 23808 KB Output is correct
22 Correct 17 ms 23808 KB Output is correct
23 Correct 16 ms 23808 KB Output is correct
24 Correct 18 ms 23936 KB Output is correct
25 Correct 16 ms 23808 KB Output is correct
26 Correct 16 ms 23808 KB Output is correct
27 Correct 16 ms 23808 KB Output is correct
28 Correct 18 ms 23936 KB Output is correct
29 Correct 16 ms 23808 KB Output is correct
30 Correct 16 ms 23900 KB Output is correct
31 Correct 16 ms 23936 KB Output is correct
32 Correct 16 ms 23808 KB Output is correct
33 Correct 16 ms 23808 KB Output is correct
34 Correct 16 ms 23808 KB Output is correct
35 Correct 16 ms 23808 KB Output is correct
36 Correct 16 ms 23808 KB Output is correct
37 Correct 17 ms 23936 KB Output is correct
38 Correct 18 ms 23808 KB Output is correct
39 Correct 78 ms 34276 KB Output is correct
40 Correct 76 ms 34296 KB Output is correct
41 Correct 57 ms 30840 KB Output is correct
42 Correct 36 ms 25472 KB Output is correct
43 Correct 17 ms 23936 KB Output is correct
44 Correct 16 ms 23808 KB Output is correct
45 Correct 20 ms 23808 KB Output is correct
46 Correct 20 ms 23808 KB Output is correct
47 Correct 17 ms 23808 KB Output is correct
48 Correct 16 ms 23808 KB Output is correct
49 Correct 17 ms 23808 KB Output is correct
50 Correct 20 ms 23808 KB Output is correct
51 Correct 17 ms 23808 KB Output is correct
52 Correct 16 ms 23808 KB Output is correct
53 Correct 16 ms 23808 KB Output is correct
54 Correct 16 ms 23808 KB Output is correct
55 Correct 16 ms 23808 KB Output is correct
56 Correct 16 ms 23808 KB Output is correct
57 Correct 159 ms 31480 KB Output is correct
58 Correct 170 ms 31480 KB Output is correct
59 Correct 116 ms 31480 KB Output is correct
60 Correct 138 ms 31480 KB Output is correct
61 Correct 105 ms 31480 KB Output is correct
62 Correct 108 ms 31480 KB Output is correct
63 Correct 96 ms 31224 KB Output is correct
64 Correct 102 ms 31224 KB Output is correct
65 Correct 104 ms 31480 KB Output is correct
66 Correct 97 ms 31480 KB Output is correct
67 Correct 103 ms 31352 KB Output is correct
68 Correct 125 ms 31512 KB Output is correct
69 Correct 116 ms 31736 KB Output is correct
70 Correct 129 ms 31736 KB Output is correct
71 Correct 17 ms 23808 KB Output is correct
72 Correct 19 ms 24064 KB Output is correct
73 Correct 19 ms 24192 KB Output is correct
74 Correct 18 ms 24064 KB Output is correct
75 Correct 22 ms 24064 KB Output is correct
76 Correct 18 ms 24064 KB Output is correct
77 Correct 18 ms 24064 KB Output is correct
78 Correct 18 ms 24064 KB Output is correct
79 Correct 19 ms 24064 KB Output is correct
80 Correct 110 ms 31444 KB Output is correct
81 Correct 109 ms 31352 KB Output is correct
82 Correct 118 ms 31608 KB Output is correct
83 Correct 107 ms 31480 KB Output is correct
84 Correct 17 ms 24064 KB Output is correct
85 Correct 18 ms 23936 KB Output is correct
86 Correct 19 ms 24064 KB Output is correct
87 Correct 19 ms 24064 KB Output is correct
88 Correct 16 ms 24040 KB Output is correct
89 Correct 16 ms 24064 KB Output is correct
90 Correct 16 ms 24064 KB Output is correct
91 Correct 16 ms 24064 KB Output is correct
92 Correct 19 ms 24064 KB Output is correct
93 Correct 15 ms 24064 KB Output is correct
94 Correct 14 ms 23808 KB Output is correct
95 Correct 16 ms 23808 KB Output is correct
96 Correct 14 ms 23808 KB Output is correct
97 Correct 15 ms 23808 KB Output is correct
98 Correct 15 ms 23808 KB Output is correct
99 Correct 15 ms 23808 KB Output is correct
100 Correct 15 ms 23808 KB Output is correct
101 Correct 18 ms 23808 KB Output is correct
102 Correct 18 ms 23808 KB Output is correct
103 Correct 15 ms 23808 KB Output is correct
104 Correct 22 ms 24704 KB Output is correct
105 Correct 29 ms 26232 KB Output is correct
106 Correct 15 ms 23808 KB Output is correct
107 Correct 44 ms 27640 KB Output is correct
108 Correct 52 ms 29176 KB Output is correct
109 Correct 18 ms 23936 KB Output is correct
110 Correct 83 ms 31096 KB Output is correct
111 Correct 90 ms 32508 KB Output is correct
112 Correct 14 ms 23936 KB Output is correct
113 Correct 134 ms 35576 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 43 ms 28028 KB Output is correct
2 Incorrect 43 ms 28024 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 34168 KB Output is correct
2 Correct 85 ms 34424 KB Output is correct
3 Correct 65 ms 30840 KB Output is correct
4 Correct 24 ms 25344 KB Output is correct
5 Correct 22 ms 24704 KB Output is correct
6 Correct 29 ms 26240 KB Output is correct
7 Correct 16 ms 23808 KB Output is correct
8 Correct 44 ms 27640 KB Output is correct
9 Correct 51 ms 29192 KB Output is correct
10 Correct 16 ms 23936 KB Output is correct
11 Correct 80 ms 30968 KB Output is correct
12 Correct 89 ms 32640 KB Output is correct
13 Correct 18 ms 23936 KB Output is correct
14 Correct 15 ms 23936 KB Output is correct
15 Correct 17 ms 23936 KB Output is correct
16 Correct 29 ms 24064 KB Output is correct
17 Correct 18 ms 23936 KB Output is correct
18 Correct 17 ms 23936 KB Output is correct
19 Correct 17 ms 24064 KB Output is correct
20 Incorrect 15 ms 23936 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 34168 KB Output is correct
2 Correct 85 ms 34424 KB Output is correct
3 Correct 65 ms 30840 KB Output is correct
4 Correct 24 ms 25344 KB Output is correct
5 Correct 22 ms 24704 KB Output is correct
6 Correct 29 ms 26240 KB Output is correct
7 Correct 16 ms 23808 KB Output is correct
8 Correct 44 ms 27640 KB Output is correct
9 Correct 51 ms 29192 KB Output is correct
10 Correct 16 ms 23936 KB Output is correct
11 Correct 80 ms 30968 KB Output is correct
12 Correct 89 ms 32640 KB Output is correct
13 Correct 18 ms 23936 KB Output is correct
14 Correct 16 ms 23808 KB Output is correct
15 Correct 16 ms 23808 KB Output is correct
16 Correct 16 ms 23808 KB Output is correct
17 Correct 16 ms 23808 KB Output is correct
18 Correct 16 ms 23808 KB Output is correct
19 Correct 16 ms 23808 KB Output is correct
20 Correct 16 ms 23808 KB Output is correct
21 Correct 16 ms 23808 KB Output is correct
22 Correct 17 ms 23808 KB Output is correct
23 Correct 16 ms 23808 KB Output is correct
24 Correct 18 ms 23936 KB Output is correct
25 Correct 16 ms 23808 KB Output is correct
26 Correct 16 ms 23808 KB Output is correct
27 Correct 16 ms 23808 KB Output is correct
28 Correct 18 ms 23936 KB Output is correct
29 Correct 16 ms 23808 KB Output is correct
30 Correct 16 ms 23900 KB Output is correct
31 Correct 16 ms 23936 KB Output is correct
32 Correct 16 ms 23808 KB Output is correct
33 Correct 16 ms 23808 KB Output is correct
34 Correct 16 ms 23808 KB Output is correct
35 Correct 16 ms 23808 KB Output is correct
36 Correct 16 ms 23808 KB Output is correct
37 Correct 17 ms 23936 KB Output is correct
38 Correct 18 ms 23808 KB Output is correct
39 Correct 78 ms 34276 KB Output is correct
40 Correct 76 ms 34296 KB Output is correct
41 Correct 57 ms 30840 KB Output is correct
42 Correct 36 ms 25472 KB Output is correct
43 Correct 17 ms 23936 KB Output is correct
44 Correct 16 ms 23808 KB Output is correct
45 Correct 20 ms 23808 KB Output is correct
46 Correct 20 ms 23808 KB Output is correct
47 Correct 17 ms 23808 KB Output is correct
48 Correct 16 ms 23808 KB Output is correct
49 Correct 17 ms 23808 KB Output is correct
50 Correct 20 ms 23808 KB Output is correct
51 Correct 17 ms 23808 KB Output is correct
52 Correct 16 ms 23808 KB Output is correct
53 Correct 16 ms 23808 KB Output is correct
54 Correct 16 ms 23808 KB Output is correct
55 Correct 16 ms 23808 KB Output is correct
56 Correct 16 ms 23808 KB Output is correct
57 Correct 159 ms 31480 KB Output is correct
58 Correct 170 ms 31480 KB Output is correct
59 Correct 116 ms 31480 KB Output is correct
60 Correct 138 ms 31480 KB Output is correct
61 Correct 105 ms 31480 KB Output is correct
62 Correct 108 ms 31480 KB Output is correct
63 Correct 96 ms 31224 KB Output is correct
64 Correct 102 ms 31224 KB Output is correct
65 Correct 104 ms 31480 KB Output is correct
66 Correct 97 ms 31480 KB Output is correct
67 Correct 103 ms 31352 KB Output is correct
68 Correct 125 ms 31512 KB Output is correct
69 Correct 116 ms 31736 KB Output is correct
70 Correct 129 ms 31736 KB Output is correct
71 Correct 17 ms 23808 KB Output is correct
72 Correct 19 ms 24064 KB Output is correct
73 Correct 19 ms 24192 KB Output is correct
74 Correct 18 ms 24064 KB Output is correct
75 Correct 22 ms 24064 KB Output is correct
76 Correct 18 ms 24064 KB Output is correct
77 Correct 18 ms 24064 KB Output is correct
78 Correct 18 ms 24064 KB Output is correct
79 Correct 19 ms 24064 KB Output is correct
80 Correct 110 ms 31444 KB Output is correct
81 Correct 109 ms 31352 KB Output is correct
82 Correct 118 ms 31608 KB Output is correct
83 Correct 107 ms 31480 KB Output is correct
84 Correct 17 ms 24064 KB Output is correct
85 Correct 18 ms 23936 KB Output is correct
86 Correct 19 ms 24064 KB Output is correct
87 Correct 19 ms 24064 KB Output is correct
88 Correct 16 ms 24040 KB Output is correct
89 Correct 16 ms 24064 KB Output is correct
90 Correct 16 ms 24064 KB Output is correct
91 Correct 16 ms 24064 KB Output is correct
92 Correct 19 ms 24064 KB Output is correct
93 Correct 15 ms 24064 KB Output is correct
94 Correct 14 ms 23808 KB Output is correct
95 Correct 16 ms 23808 KB Output is correct
96 Correct 14 ms 23808 KB Output is correct
97 Correct 15 ms 23808 KB Output is correct
98 Correct 15 ms 23808 KB Output is correct
99 Correct 15 ms 23808 KB Output is correct
100 Correct 15 ms 23808 KB Output is correct
101 Correct 18 ms 23808 KB Output is correct
102 Correct 18 ms 23808 KB Output is correct
103 Correct 15 ms 23808 KB Output is correct
104 Correct 22 ms 24704 KB Output is correct
105 Correct 29 ms 26232 KB Output is correct
106 Correct 15 ms 23808 KB Output is correct
107 Correct 44 ms 27640 KB Output is correct
108 Correct 52 ms 29176 KB Output is correct
109 Correct 18 ms 23936 KB Output is correct
110 Correct 83 ms 31096 KB Output is correct
111 Correct 90 ms 32508 KB Output is correct
112 Correct 14 ms 23936 KB Output is correct
113 Correct 134 ms 35576 KB Output is correct
114 Correct 43 ms 28028 KB Output is correct
115 Incorrect 43 ms 28024 KB Output isn't correct
116 Halted 0 ms 0 KB -