답안 #56305

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
56305 2018-07-11T03:53:11 Z 윤교준(#1600) Construction of Highway (JOI18_construction) C++11
7 / 100
1000 ms 1884 KB
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
using namespace std;
typedef long long ll;

const int MAXN = 100005;

int prt[MAXN];

int A[MAXN], B[MAXN], C[MAXN];

int N;

int main() {
	ios::sync_with_stdio(false);

	cin >> N;
	for(int i = 1; i <= N; i++) cin >> C[i];
	for(int i = 1; i < N; i++) cin >> A[i] >> B[i];

	for(int qi = 1, a, b; qi < N; qi++) {
		a = A[qi]; b = B[qi];

		vector<int> V;
		for(int i = a; 1 < i; i = prt[i]) V.pb(i);
		V.pb(1);
		revv(V);

		int ret = 0;
		for(int i = 0; i < sz(V); i++) for(int j = i+1; j < sz(V); j++)
			if(C[V[i]] > C[V[j]]) ret++;

		for(int v : V) C[v] = C[b];

		prt[b] = a;

		printf("%d\n", ret);
	}
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 624 KB Output is correct
3 Correct 3 ms 680 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 3 ms 680 KB Output is correct
6 Correct 2 ms 836 KB Output is correct
7 Correct 4 ms 836 KB Output is correct
8 Correct 32 ms 836 KB Output is correct
9 Correct 27 ms 848 KB Output is correct
10 Correct 27 ms 848 KB Output is correct
11 Correct 11 ms 872 KB Output is correct
12 Correct 11 ms 1012 KB Output is correct
13 Correct 10 ms 1036 KB Output is correct
14 Correct 9 ms 1036 KB Output is correct
15 Correct 3 ms 1044 KB Output is correct
16 Correct 3 ms 1044 KB Output is correct
17 Correct 4 ms 1064 KB Output is correct
18 Correct 4 ms 1260 KB Output is correct
19 Correct 14 ms 1260 KB Output is correct
20 Correct 9 ms 1260 KB Output is correct
21 Correct 10 ms 1260 KB Output is correct
22 Correct 3 ms 1364 KB Output is correct
23 Correct 2 ms 1364 KB Output is correct
24 Correct 3 ms 1364 KB Output is correct
25 Correct 2 ms 1364 KB Output is correct
26 Correct 28 ms 1444 KB Output is correct
27 Correct 12 ms 1444 KB Output is correct
28 Correct 15 ms 1444 KB Output is correct
29 Correct 10 ms 1444 KB Output is correct
30 Correct 2 ms 1444 KB Output is correct
31 Correct 3 ms 1444 KB Output is correct
32 Correct 11 ms 1444 KB Output is correct
33 Correct 5 ms 1444 KB Output is correct
34 Correct 5 ms 1444 KB Output is correct
35 Correct 3 ms 1444 KB Output is correct
36 Correct 4 ms 1444 KB Output is correct
37 Correct 4 ms 1444 KB Output is correct
38 Correct 3 ms 1444 KB Output is correct
39 Correct 5 ms 1444 KB Output is correct
40 Correct 4 ms 1444 KB Output is correct
41 Correct 3 ms 1444 KB Output is correct
42 Correct 5 ms 1444 KB Output is correct
43 Correct 4 ms 1476 KB Output is correct
44 Correct 3 ms 1476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 624 KB Output is correct
3 Correct 3 ms 680 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 3 ms 680 KB Output is correct
6 Correct 2 ms 836 KB Output is correct
7 Correct 4 ms 836 KB Output is correct
8 Correct 32 ms 836 KB Output is correct
9 Correct 27 ms 848 KB Output is correct
10 Correct 27 ms 848 KB Output is correct
11 Correct 11 ms 872 KB Output is correct
12 Correct 11 ms 1012 KB Output is correct
13 Correct 10 ms 1036 KB Output is correct
14 Correct 9 ms 1036 KB Output is correct
15 Correct 3 ms 1044 KB Output is correct
16 Correct 3 ms 1044 KB Output is correct
17 Correct 4 ms 1064 KB Output is correct
18 Correct 4 ms 1260 KB Output is correct
19 Correct 14 ms 1260 KB Output is correct
20 Correct 9 ms 1260 KB Output is correct
21 Correct 10 ms 1260 KB Output is correct
22 Correct 3 ms 1364 KB Output is correct
23 Correct 2 ms 1364 KB Output is correct
24 Correct 3 ms 1364 KB Output is correct
25 Correct 2 ms 1364 KB Output is correct
26 Correct 28 ms 1444 KB Output is correct
27 Correct 12 ms 1444 KB Output is correct
28 Correct 15 ms 1444 KB Output is correct
29 Correct 10 ms 1444 KB Output is correct
30 Correct 2 ms 1444 KB Output is correct
31 Correct 3 ms 1444 KB Output is correct
32 Correct 11 ms 1444 KB Output is correct
33 Correct 5 ms 1444 KB Output is correct
34 Correct 5 ms 1444 KB Output is correct
35 Correct 3 ms 1444 KB Output is correct
36 Correct 4 ms 1444 KB Output is correct
37 Correct 4 ms 1444 KB Output is correct
38 Correct 3 ms 1444 KB Output is correct
39 Correct 5 ms 1444 KB Output is correct
40 Correct 4 ms 1444 KB Output is correct
41 Correct 3 ms 1444 KB Output is correct
42 Correct 5 ms 1444 KB Output is correct
43 Correct 4 ms 1476 KB Output is correct
44 Correct 3 ms 1476 KB Output is correct
45 Correct 4 ms 1476 KB Output is correct
46 Correct 10 ms 1632 KB Output is correct
47 Correct 6 ms 1648 KB Output is correct
48 Correct 6 ms 1760 KB Output is correct
49 Execution timed out 1076 ms 1884 KB Time limit exceeded
50 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 3 ms 624 KB Output is correct
3 Correct 3 ms 680 KB Output is correct
4 Correct 2 ms 680 KB Output is correct
5 Correct 3 ms 680 KB Output is correct
6 Correct 2 ms 836 KB Output is correct
7 Correct 4 ms 836 KB Output is correct
8 Correct 32 ms 836 KB Output is correct
9 Correct 27 ms 848 KB Output is correct
10 Correct 27 ms 848 KB Output is correct
11 Correct 11 ms 872 KB Output is correct
12 Correct 11 ms 1012 KB Output is correct
13 Correct 10 ms 1036 KB Output is correct
14 Correct 9 ms 1036 KB Output is correct
15 Correct 3 ms 1044 KB Output is correct
16 Correct 3 ms 1044 KB Output is correct
17 Correct 4 ms 1064 KB Output is correct
18 Correct 4 ms 1260 KB Output is correct
19 Correct 14 ms 1260 KB Output is correct
20 Correct 9 ms 1260 KB Output is correct
21 Correct 10 ms 1260 KB Output is correct
22 Correct 3 ms 1364 KB Output is correct
23 Correct 2 ms 1364 KB Output is correct
24 Correct 3 ms 1364 KB Output is correct
25 Correct 2 ms 1364 KB Output is correct
26 Correct 28 ms 1444 KB Output is correct
27 Correct 12 ms 1444 KB Output is correct
28 Correct 15 ms 1444 KB Output is correct
29 Correct 10 ms 1444 KB Output is correct
30 Correct 2 ms 1444 KB Output is correct
31 Correct 3 ms 1444 KB Output is correct
32 Correct 11 ms 1444 KB Output is correct
33 Correct 5 ms 1444 KB Output is correct
34 Correct 5 ms 1444 KB Output is correct
35 Correct 3 ms 1444 KB Output is correct
36 Correct 4 ms 1444 KB Output is correct
37 Correct 4 ms 1444 KB Output is correct
38 Correct 3 ms 1444 KB Output is correct
39 Correct 5 ms 1444 KB Output is correct
40 Correct 4 ms 1444 KB Output is correct
41 Correct 3 ms 1444 KB Output is correct
42 Correct 5 ms 1444 KB Output is correct
43 Correct 4 ms 1476 KB Output is correct
44 Correct 3 ms 1476 KB Output is correct
45 Correct 4 ms 1476 KB Output is correct
46 Correct 10 ms 1632 KB Output is correct
47 Correct 6 ms 1648 KB Output is correct
48 Correct 6 ms 1760 KB Output is correct
49 Execution timed out 1076 ms 1884 KB Time limit exceeded
50 Halted 0 ms 0 KB -