# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
47383 | 2018-05-02T09:09:02 Z | mirbek01 | Construction of Highway (JOI18_construction) | C++17 | 1000 ms | 10068 KB |
# include <bits/stdc++.h> using namespace std; const int N = 1e5 + 2; int n, c[N], p[N], fen[N]; vector <int> vec; void update(int pos, int val){ for(; pos <= n; pos |= pos + 1) fen[pos] += val; } int get(int pos){ int res = 0; for(; pos > 0; pos = (pos & (pos + 1)) - 1) res += fen[pos]; return res; } int main(){ scanf("%d", &n); for(int i = 1; i <= n; i ++){ scanf("%d", &c[i]); vec.emplace_back(c[i]); } sort(vec.begin(), vec.end()); vec.resize(unique(vec.begin(), vec.end()) - vec.begin()); for(int i = 1; i <= n; i ++){ c[i] = lower_bound(vec.begin(), vec.end(), c[i]) - vec.begin() + 1; } for(int i = 1; i < n; i ++){ int a, b; scanf("%d %d", &a, &b); int v = a, ans = 0; while(v){ update(c[v], 1); ans += get(c[v] - 1); v = p[v]; } v = a; while(v){ update(c[v], -1); c[v] = c[b]; v = p[v]; } printf("%d\n", ans); p[b] = a; } }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 2 ms | 448 KB | Output is correct |
5 | Correct | 2 ms | 484 KB | Output is correct |
6 | Correct | 2 ms | 540 KB | Output is correct |
7 | Correct | 2 ms | 540 KB | Output is correct |
8 | Correct | 4 ms | 560 KB | Output is correct |
9 | Correct | 4 ms | 560 KB | Output is correct |
10 | Correct | 6 ms | 560 KB | Output is correct |
11 | Correct | 4 ms | 572 KB | Output is correct |
12 | Correct | 4 ms | 816 KB | Output is correct |
13 | Correct | 3 ms | 816 KB | Output is correct |
14 | Correct | 3 ms | 816 KB | Output is correct |
15 | Correct | 3 ms | 816 KB | Output is correct |
16 | Correct | 2 ms | 816 KB | Output is correct |
17 | Correct | 2 ms | 816 KB | Output is correct |
18 | Correct | 2 ms | 816 KB | Output is correct |
19 | Correct | 3 ms | 816 KB | Output is correct |
20 | Correct | 3 ms | 816 KB | Output is correct |
21 | Correct | 3 ms | 816 KB | Output is correct |
22 | Correct | 3 ms | 816 KB | Output is correct |
23 | Correct | 3 ms | 816 KB | Output is correct |
24 | Correct | 2 ms | 816 KB | Output is correct |
25 | Correct | 2 ms | 816 KB | Output is correct |
26 | Correct | 5 ms | 816 KB | Output is correct |
27 | Correct | 3 ms | 816 KB | Output is correct |
28 | Correct | 22 ms | 816 KB | Output is correct |
29 | Correct | 3 ms | 816 KB | Output is correct |
30 | Correct | 2 ms | 816 KB | Output is correct |
31 | Correct | 2 ms | 816 KB | Output is correct |
32 | Correct | 4 ms | 816 KB | Output is correct |
33 | Correct | 3 ms | 816 KB | Output is correct |
34 | Correct | 2 ms | 816 KB | Output is correct |
35 | Correct | 3 ms | 816 KB | Output is correct |
36 | Correct | 3 ms | 816 KB | Output is correct |
37 | Correct | 3 ms | 816 KB | Output is correct |
38 | Correct | 2 ms | 816 KB | Output is correct |
39 | Correct | 3 ms | 816 KB | Output is correct |
40 | Correct | 3 ms | 816 KB | Output is correct |
41 | Correct | 3 ms | 816 KB | Output is correct |
42 | Correct | 3 ms | 816 KB | Output is correct |
43 | Correct | 3 ms | 816 KB | Output is correct |
44 | Correct | 3 ms | 816 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 2 ms | 448 KB | Output is correct |
5 | Correct | 2 ms | 484 KB | Output is correct |
6 | Correct | 2 ms | 540 KB | Output is correct |
7 | Correct | 2 ms | 540 KB | Output is correct |
8 | Correct | 4 ms | 560 KB | Output is correct |
9 | Correct | 4 ms | 560 KB | Output is correct |
10 | Correct | 6 ms | 560 KB | Output is correct |
11 | Correct | 4 ms | 572 KB | Output is correct |
12 | Correct | 4 ms | 816 KB | Output is correct |
13 | Correct | 3 ms | 816 KB | Output is correct |
14 | Correct | 3 ms | 816 KB | Output is correct |
15 | Correct | 3 ms | 816 KB | Output is correct |
16 | Correct | 2 ms | 816 KB | Output is correct |
17 | Correct | 2 ms | 816 KB | Output is correct |
18 | Correct | 2 ms | 816 KB | Output is correct |
19 | Correct | 3 ms | 816 KB | Output is correct |
20 | Correct | 3 ms | 816 KB | Output is correct |
21 | Correct | 3 ms | 816 KB | Output is correct |
22 | Correct | 3 ms | 816 KB | Output is correct |
23 | Correct | 3 ms | 816 KB | Output is correct |
24 | Correct | 2 ms | 816 KB | Output is correct |
25 | Correct | 2 ms | 816 KB | Output is correct |
26 | Correct | 5 ms | 816 KB | Output is correct |
27 | Correct | 3 ms | 816 KB | Output is correct |
28 | Correct | 22 ms | 816 KB | Output is correct |
29 | Correct | 3 ms | 816 KB | Output is correct |
30 | Correct | 2 ms | 816 KB | Output is correct |
31 | Correct | 2 ms | 816 KB | Output is correct |
32 | Correct | 4 ms | 816 KB | Output is correct |
33 | Correct | 3 ms | 816 KB | Output is correct |
34 | Correct | 2 ms | 816 KB | Output is correct |
35 | Correct | 3 ms | 816 KB | Output is correct |
36 | Correct | 3 ms | 816 KB | Output is correct |
37 | Correct | 3 ms | 816 KB | Output is correct |
38 | Correct | 2 ms | 816 KB | Output is correct |
39 | Correct | 3 ms | 816 KB | Output is correct |
40 | Correct | 3 ms | 816 KB | Output is correct |
41 | Correct | 3 ms | 816 KB | Output is correct |
42 | Correct | 3 ms | 816 KB | Output is correct |
43 | Correct | 3 ms | 816 KB | Output is correct |
44 | Correct | 3 ms | 816 KB | Output is correct |
45 | Correct | 3 ms | 816 KB | Output is correct |
46 | Correct | 9 ms | 816 KB | Output is correct |
47 | Correct | 7 ms | 816 KB | Output is correct |
48 | Correct | 7 ms | 816 KB | Output is correct |
49 | Correct | 199 ms | 816 KB | Output is correct |
50 | Correct | 210 ms | 816 KB | Output is correct |
51 | Correct | 263 ms | 816 KB | Output is correct |
52 | Correct | 103 ms | 816 KB | Output is correct |
53 | Correct | 101 ms | 816 KB | Output is correct |
54 | Correct | 105 ms | 956 KB | Output is correct |
55 | Correct | 118 ms | 956 KB | Output is correct |
56 | Correct | 100 ms | 956 KB | Output is correct |
57 | Correct | 7 ms | 956 KB | Output is correct |
58 | Correct | 7 ms | 956 KB | Output is correct |
59 | Correct | 8 ms | 956 KB | Output is correct |
60 | Correct | 7 ms | 956 KB | Output is correct |
61 | Correct | 122 ms | 956 KB | Output is correct |
62 | Correct | 130 ms | 956 KB | Output is correct |
63 | Correct | 110 ms | 956 KB | Output is correct |
64 | Correct | 5 ms | 956 KB | Output is correct |
65 | Correct | 6 ms | 956 KB | Output is correct |
66 | Correct | 9 ms | 956 KB | Output is correct |
67 | Correct | 5 ms | 956 KB | Output is correct |
68 | Correct | 264 ms | 956 KB | Output is correct |
69 | Correct | 111 ms | 956 KB | Output is correct |
70 | Correct | 127 ms | 956 KB | Output is correct |
71 | Correct | 126 ms | 956 KB | Output is correct |
72 | Correct | 6 ms | 956 KB | Output is correct |
73 | Correct | 7 ms | 956 KB | Output is correct |
74 | Correct | 132 ms | 956 KB | Output is correct |
75 | Correct | 56 ms | 956 KB | Output is correct |
76 | Correct | 42 ms | 956 KB | Output is correct |
77 | Correct | 30 ms | 956 KB | Output is correct |
78 | Correct | 65 ms | 956 KB | Output is correct |
79 | Correct | 47 ms | 956 KB | Output is correct |
80 | Correct | 41 ms | 956 KB | Output is correct |
81 | Correct | 60 ms | 956 KB | Output is correct |
82 | Correct | 37 ms | 956 KB | Output is correct |
83 | Correct | 29 ms | 956 KB | Output is correct |
84 | Correct | 67 ms | 956 KB | Output is correct |
85 | Correct | 45 ms | 956 KB | Output is correct |
86 | Correct | 36 ms | 956 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 248 KB | Output is correct |
2 | Correct | 2 ms | 356 KB | Output is correct |
3 | Correct | 2 ms | 432 KB | Output is correct |
4 | Correct | 2 ms | 448 KB | Output is correct |
5 | Correct | 2 ms | 484 KB | Output is correct |
6 | Correct | 2 ms | 540 KB | Output is correct |
7 | Correct | 2 ms | 540 KB | Output is correct |
8 | Correct | 4 ms | 560 KB | Output is correct |
9 | Correct | 4 ms | 560 KB | Output is correct |
10 | Correct | 6 ms | 560 KB | Output is correct |
11 | Correct | 4 ms | 572 KB | Output is correct |
12 | Correct | 4 ms | 816 KB | Output is correct |
13 | Correct | 3 ms | 816 KB | Output is correct |
14 | Correct | 3 ms | 816 KB | Output is correct |
15 | Correct | 3 ms | 816 KB | Output is correct |
16 | Correct | 2 ms | 816 KB | Output is correct |
17 | Correct | 2 ms | 816 KB | Output is correct |
18 | Correct | 2 ms | 816 KB | Output is correct |
19 | Correct | 3 ms | 816 KB | Output is correct |
20 | Correct | 3 ms | 816 KB | Output is correct |
21 | Correct | 3 ms | 816 KB | Output is correct |
22 | Correct | 3 ms | 816 KB | Output is correct |
23 | Correct | 3 ms | 816 KB | Output is correct |
24 | Correct | 2 ms | 816 KB | Output is correct |
25 | Correct | 2 ms | 816 KB | Output is correct |
26 | Correct | 5 ms | 816 KB | Output is correct |
27 | Correct | 3 ms | 816 KB | Output is correct |
28 | Correct | 22 ms | 816 KB | Output is correct |
29 | Correct | 3 ms | 816 KB | Output is correct |
30 | Correct | 2 ms | 816 KB | Output is correct |
31 | Correct | 2 ms | 816 KB | Output is correct |
32 | Correct | 4 ms | 816 KB | Output is correct |
33 | Correct | 3 ms | 816 KB | Output is correct |
34 | Correct | 2 ms | 816 KB | Output is correct |
35 | Correct | 3 ms | 816 KB | Output is correct |
36 | Correct | 3 ms | 816 KB | Output is correct |
37 | Correct | 3 ms | 816 KB | Output is correct |
38 | Correct | 2 ms | 816 KB | Output is correct |
39 | Correct | 3 ms | 816 KB | Output is correct |
40 | Correct | 3 ms | 816 KB | Output is correct |
41 | Correct | 3 ms | 816 KB | Output is correct |
42 | Correct | 3 ms | 816 KB | Output is correct |
43 | Correct | 3 ms | 816 KB | Output is correct |
44 | Correct | 3 ms | 816 KB | Output is correct |
45 | Correct | 3 ms | 816 KB | Output is correct |
46 | Correct | 9 ms | 816 KB | Output is correct |
47 | Correct | 7 ms | 816 KB | Output is correct |
48 | Correct | 7 ms | 816 KB | Output is correct |
49 | Correct | 199 ms | 816 KB | Output is correct |
50 | Correct | 210 ms | 816 KB | Output is correct |
51 | Correct | 263 ms | 816 KB | Output is correct |
52 | Correct | 103 ms | 816 KB | Output is correct |
53 | Correct | 101 ms | 816 KB | Output is correct |
54 | Correct | 105 ms | 956 KB | Output is correct |
55 | Correct | 118 ms | 956 KB | Output is correct |
56 | Correct | 100 ms | 956 KB | Output is correct |
57 | Correct | 7 ms | 956 KB | Output is correct |
58 | Correct | 7 ms | 956 KB | Output is correct |
59 | Correct | 8 ms | 956 KB | Output is correct |
60 | Correct | 7 ms | 956 KB | Output is correct |
61 | Correct | 122 ms | 956 KB | Output is correct |
62 | Correct | 130 ms | 956 KB | Output is correct |
63 | Correct | 110 ms | 956 KB | Output is correct |
64 | Correct | 5 ms | 956 KB | Output is correct |
65 | Correct | 6 ms | 956 KB | Output is correct |
66 | Correct | 9 ms | 956 KB | Output is correct |
67 | Correct | 5 ms | 956 KB | Output is correct |
68 | Correct | 264 ms | 956 KB | Output is correct |
69 | Correct | 111 ms | 956 KB | Output is correct |
70 | Correct | 127 ms | 956 KB | Output is correct |
71 | Correct | 126 ms | 956 KB | Output is correct |
72 | Correct | 6 ms | 956 KB | Output is correct |
73 | Correct | 7 ms | 956 KB | Output is correct |
74 | Correct | 132 ms | 956 KB | Output is correct |
75 | Correct | 56 ms | 956 KB | Output is correct |
76 | Correct | 42 ms | 956 KB | Output is correct |
77 | Correct | 30 ms | 956 KB | Output is correct |
78 | Correct | 65 ms | 956 KB | Output is correct |
79 | Correct | 47 ms | 956 KB | Output is correct |
80 | Correct | 41 ms | 956 KB | Output is correct |
81 | Correct | 60 ms | 956 KB | Output is correct |
82 | Correct | 37 ms | 956 KB | Output is correct |
83 | Correct | 29 ms | 956 KB | Output is correct |
84 | Correct | 67 ms | 956 KB | Output is correct |
85 | Correct | 45 ms | 956 KB | Output is correct |
86 | Correct | 36 ms | 956 KB | Output is correct |
87 | Correct | 15 ms | 956 KB | Output is correct |
88 | Correct | 43 ms | 1340 KB | Output is correct |
89 | Correct | 185 ms | 4796 KB | Output is correct |
90 | Correct | 178 ms | 7044 KB | Output is correct |
91 | Correct | 183 ms | 9080 KB | Output is correct |
92 | Execution timed out | 1079 ms | 10068 KB | Time limit exceeded |
93 | Halted | 0 ms | 0 KB | - |