답안 #850676

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
850676 2023-09-17T09:15:22 Z TahirAliyev Vinjete (COI22_vinjete) C++17
24 / 100
5 ms 804 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
#define oo 1e9
#define pii pair<ll, int>

const int MAX = 1002;
int n, m;
vector<array<int, 3>> g[MAX];

pii combine(pii a, pii b){
    if(a.second < b.first - 1 || b.second < a.first - 1){
        return {-1, -1};
    }
    return {min(a.first, b.first), max(a.second, b.second)};
}

set<pii> s;
int ans[MAX];

void dfs(int node, int p, int l, int r){
    vector<pii> del;
    for(auto& a : s){
        pii c = combine(a, {l, r});
        if(c.first == -1){
            ans[node] += a.second - a.first + 1;
            continue;
        }
        del.push_back(a);
        l = c.first, r = c.second;
    }
    for(auto& a : del){
        s.erase(a);
    }
    ans[node] += r - l + 1;
    if(node != 1){
        s.insert({l, r});
    }
    for(auto to : g[node]){
        if(p == to[0]) continue;
        dfs(to[0], node, to[1], to[2]);
    }
    s.erase({l, r});
    for(auto& a : del){
        s.insert(a);
    }
}


int main(){
    cin >> n >> m;
    for(int i = 1; i < n; i++){
        int a, b, l, r; cin >> a >> b >> l >> r;
        g[a].push_back({b, l, r});
        g[b].push_back({a, l, r});
    }
    dfs(1, 1, 0, 0);
    for(int i = 2; i <= n; i++){
        cout << ans[i] << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 1 ms 600 KB Output is correct
27 Correct 2 ms 804 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 5 ms 600 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 3 ms 600 KB Output is correct
32 Correct 3 ms 600 KB Output is correct
33 Correct 4 ms 600 KB Output is correct
34 Correct 3 ms 600 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 2 ms 344 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 2 ms 600 KB Output is correct
40 Correct 2 ms 344 KB Output is correct
41 Correct 2 ms 344 KB Output is correct
42 Correct 2 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 344 KB Output is correct
46 Correct 2 ms 344 KB Output is correct
47 Correct 2 ms 344 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 2 ms 348 KB Output is correct
50 Correct 2 ms 344 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Runtime error 3 ms 600 KB Execution killed with signal 6
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Runtime error 3 ms 600 KB Execution killed with signal 6
26 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 600 KB Output is correct
2 Correct 1 ms 600 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 3 ms 600 KB Output is correct
6 Correct 3 ms 604 KB Output is correct
7 Correct 0 ms 344 KB Output is correct
8 Correct 1 ms 344 KB Output is correct
9 Correct 1 ms 344 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 1 ms 344 KB Output is correct
12 Correct 2 ms 344 KB Output is correct
13 Correct 2 ms 344 KB Output is correct
14 Correct 2 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 2 ms 344 KB Output is correct
19 Correct 1 ms 344 KB Output is correct
20 Correct 1 ms 344 KB Output is correct
21 Correct 1 ms 348 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 1 ms 344 KB Output is correct
25 Correct 1 ms 600 KB Output is correct
26 Correct 1 ms 600 KB Output is correct
27 Correct 2 ms 804 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 5 ms 600 KB Output is correct
30 Correct 4 ms 604 KB Output is correct
31 Correct 3 ms 600 KB Output is correct
32 Correct 3 ms 600 KB Output is correct
33 Correct 4 ms 600 KB Output is correct
34 Correct 3 ms 600 KB Output is correct
35 Correct 1 ms 344 KB Output is correct
36 Correct 1 ms 344 KB Output is correct
37 Correct 2 ms 344 KB Output is correct
38 Correct 2 ms 344 KB Output is correct
39 Correct 2 ms 600 KB Output is correct
40 Correct 2 ms 344 KB Output is correct
41 Correct 2 ms 344 KB Output is correct
42 Correct 2 ms 344 KB Output is correct
43 Correct 1 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 344 KB Output is correct
46 Correct 2 ms 344 KB Output is correct
47 Correct 2 ms 344 KB Output is correct
48 Correct 1 ms 344 KB Output is correct
49 Correct 2 ms 348 KB Output is correct
50 Correct 2 ms 344 KB Output is correct
51 Runtime error 3 ms 600 KB Execution killed with signal 6
52 Halted 0 ms 0 KB -