답안 #892693

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
892693 2023-12-25T16:54:05 Z box Construction of Highway (JOI18_construction) C++17
7 / 100
18 ms 1568 KB
#include <bits/stdc++.h>
using namespace std;

#define ar array
#define sz(v) int(std::size(v))
using i64 = long long;
using pii = pair<int, int>;

const int N = 500;

int n, c[N];
vector<int> adj[N];
vector<int> path[N];
vector<pii> con;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> c[i];
    for (int h = 0; h < n - 1; h++) {
        int i, j;
        cin >> i >> j, i--, j--;
        adj[i].push_back(j);
        adj[j].push_back(i);
        con.push_back({i, j});
    }
    path[0] = {0};
    for (auto [i, j] : con) {
        path[j] = path[i];
        path[j].push_back(j);
        int cost = 0;
        for (int x = 0; x < sz(path[i]); x++) for (int y = x + 1; y < sz(path[i]); y++)
            cost += c[path[i][x]] > c[path[i][y]];
        for (int v : path[j]) c[v] = c[j];
        cout << cost << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 18 ms 1568 KB Output is correct
9 Correct 18 ms 1368 KB Output is correct
10 Correct 18 ms 1372 KB Output is correct
11 Correct 6 ms 860 KB Output is correct
12 Correct 5 ms 860 KB Output is correct
13 Correct 5 ms 884 KB Output is correct
14 Correct 5 ms 1000 KB Output is correct
15 Correct 0 ms 488 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 5 ms 860 KB Output is correct
20 Correct 5 ms 860 KB Output is correct
21 Correct 5 ms 860 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 360 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 18 ms 1372 KB Output is correct
27 Correct 7 ms 1116 KB Output is correct
28 Correct 5 ms 1000 KB Output is correct
29 Correct 5 ms 860 KB Output is correct
30 Correct 0 ms 488 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 5 ms 1024 KB Output is correct
33 Correct 2 ms 600 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 1 ms 608 KB Output is correct
42 Correct 2 ms 720 KB Output is correct
43 Correct 1 ms 608 KB Output is correct
44 Correct 1 ms 608 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 18 ms 1568 KB Output is correct
9 Correct 18 ms 1368 KB Output is correct
10 Correct 18 ms 1372 KB Output is correct
11 Correct 6 ms 860 KB Output is correct
12 Correct 5 ms 860 KB Output is correct
13 Correct 5 ms 884 KB Output is correct
14 Correct 5 ms 1000 KB Output is correct
15 Correct 0 ms 488 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 5 ms 860 KB Output is correct
20 Correct 5 ms 860 KB Output is correct
21 Correct 5 ms 860 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 360 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 18 ms 1372 KB Output is correct
27 Correct 7 ms 1116 KB Output is correct
28 Correct 5 ms 1000 KB Output is correct
29 Correct 5 ms 860 KB Output is correct
30 Correct 0 ms 488 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 5 ms 1024 KB Output is correct
33 Correct 2 ms 600 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 1 ms 608 KB Output is correct
42 Correct 2 ms 720 KB Output is correct
43 Correct 1 ms 608 KB Output is correct
44 Correct 1 ms 608 KB Output is correct
45 Runtime error 1 ms 604 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 18 ms 1568 KB Output is correct
9 Correct 18 ms 1368 KB Output is correct
10 Correct 18 ms 1372 KB Output is correct
11 Correct 6 ms 860 KB Output is correct
12 Correct 5 ms 860 KB Output is correct
13 Correct 5 ms 884 KB Output is correct
14 Correct 5 ms 1000 KB Output is correct
15 Correct 0 ms 488 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 348 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 5 ms 860 KB Output is correct
20 Correct 5 ms 860 KB Output is correct
21 Correct 5 ms 860 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 ms 360 KB Output is correct
25 Correct 1 ms 348 KB Output is correct
26 Correct 18 ms 1372 KB Output is correct
27 Correct 7 ms 1116 KB Output is correct
28 Correct 5 ms 1000 KB Output is correct
29 Correct 5 ms 860 KB Output is correct
30 Correct 0 ms 488 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 5 ms 1024 KB Output is correct
33 Correct 2 ms 600 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 1 ms 600 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 1 ms 604 KB Output is correct
41 Correct 1 ms 608 KB Output is correct
42 Correct 2 ms 720 KB Output is correct
43 Correct 1 ms 608 KB Output is correct
44 Correct 1 ms 608 KB Output is correct
45 Runtime error 1 ms 604 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -