답안 #960876

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
960876 2024-04-11T07:12:25 Z Pring Vinjete (COI22_vinjete) C++17
100 / 100
229 ms 32264 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef MIKU
string dbmc = "\033[1;38;2;57;197;187m", dbrs = "\033[0m";
#define debug(x...) cout << dbmc << "[" << #x << "]: ", dout(x)
void dout() { cout << dbrs << endl; }
template <typename T, typename ...U>
void dout(T t, U ...u) { cout << t << (sizeof...(u) ? ", " : ""); dout(u...); }
#else
#define debug(...) 39
#endif

#define fs first
#define sc second
#define mp make_pair
#define FOR(i, j, k) for (int i = j, Z = k; i < Z; i++)
using ll = long long;
typedef pair<int, int> pii;

const int MXN = 200005;
int n, m, eu[MXN], ev[MXN], el[MXN], er[MXN], ans[MXN];
int N;
vector<int> eid[MXN];
vector<pii> dist;

struct SMG {
    #define mid ((l + r) >> 1)
    int b[MXN * 4], c[MXN * 4];
    void UPD(int id, int l, int r) {
        if (b[id]) c[id] = dist[r].fs - dist[l].fs;
        else {
            c[id] = 0;
            if (l + 1 < r) c[id] = c[id * 2 + 1] + c[id * 2 + 2];
        }
    }
    void ADD(int id, int l, int r, int _l, int _r) {
        if (_l <= l && r <= _r) {
            b[id]++;
            UPD(id, l, r);
            return;
        }
        if (_l < mid) ADD(id * 2 + 1, l, mid, _l, _r);
        if (mid < _r) ADD(id * 2 + 2, mid, r, _l, _r);
        UPD(id, l, r);
    }
    void REM(int id, int l, int r, int _l, int _r) {
        if (_l <= l && r <= _r) {
            b[id]--;
            UPD(id, l, r);
            return;
        }
        if (_l < mid) REM(id * 2 + 1, l, mid, _l, _r);
        if (mid < _r) REM(id * 2 + 2, mid, r, _l, _r);
        UPD(id, l, r);
    }
} smg;

void DIST() {
    FOR(i, 1, n) {
        dist.push_back(mp(el[i], i));
        dist.push_back(mp(er[i], i + n));
    }
    sort(dist.begin(), dist.end());
    FOR(i, 0, dist.size()) {
        auto [_, id] = dist[i];
        if (id < n) el[id] = i;
        else er[id - n] = i;
    }
}

void DFS(int id, int par) {
    ans[id] = smg.c[0];
    for (auto &e : eid[id]) {
        int i = eu[e] ^ ev[e] ^ id;
        if (i == par) continue;
        debug(el[e], er[e], '+');
        smg.ADD(0, 0, N, el[e], er[e]);
        DFS(i, id);
        debug(el[e], er[e], '-');
        smg.REM(0, 0, N, el[e], er[e]);
    }
}

void miku() {
    cin >> n >> m;
    N = 2 * n - 2;
    FOR(i, 1, n) {
        cin >> eu[i] >> ev[i] >> el[i] >> er[i];
        er[i]++;
        eid[eu[i]].push_back(i);
        eid[ev[i]].push_back(i);
    }
    DIST();
    DFS(1, 0);
    FOR(i, 2, n + 1) cout << ans[i] << '\n';
}

int32_t main() {
    cin.tie(0) -> sync_with_stdio(false);
    cin.exceptions(cin.failbit);
    miku();
    return 0;
}

Compilation message

Main.cpp: In function 'void DFS(int, int)':
Main.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 39
      |                    ^~
Main.cpp:77:9: note: in expansion of macro 'debug'
   77 |         debug(el[e], er[e], '+');
      |         ^~~~~
Main.cpp:11:20: warning: statement has no effect [-Wunused-value]
   11 | #define debug(...) 39
      |                    ^~
Main.cpp:80:9: note: in expansion of macro 'debug'
   80 |         debug(el[e], er[e], '-');
      |         ^~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10844 KB Output is correct
2 Correct 4 ms 10844 KB Output is correct
3 Correct 4 ms 10844 KB Output is correct
4 Correct 3 ms 10844 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10840 KB Output is correct
7 Correct 4 ms 10588 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 4 ms 10840 KB Output is correct
11 Correct 3 ms 10840 KB Output is correct
12 Correct 4 ms 10844 KB Output is correct
13 Correct 3 ms 10840 KB Output is correct
14 Correct 3 ms 10844 KB Output is correct
15 Correct 2 ms 10724 KB Output is correct
16 Correct 2 ms 10588 KB Output is correct
17 Correct 4 ms 10844 KB Output is correct
18 Correct 3 ms 10844 KB Output is correct
19 Correct 3 ms 10840 KB Output is correct
20 Correct 3 ms 10672 KB Output is correct
21 Correct 3 ms 10844 KB Output is correct
22 Correct 3 ms 10840 KB Output is correct
23 Correct 2 ms 10584 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10844 KB Output is correct
2 Correct 4 ms 10844 KB Output is correct
3 Correct 4 ms 10844 KB Output is correct
4 Correct 3 ms 10844 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10840 KB Output is correct
7 Correct 4 ms 10588 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 4 ms 10840 KB Output is correct
11 Correct 3 ms 10840 KB Output is correct
12 Correct 4 ms 10844 KB Output is correct
13 Correct 3 ms 10840 KB Output is correct
14 Correct 3 ms 10844 KB Output is correct
15 Correct 2 ms 10724 KB Output is correct
16 Correct 2 ms 10588 KB Output is correct
17 Correct 4 ms 10844 KB Output is correct
18 Correct 3 ms 10844 KB Output is correct
19 Correct 3 ms 10840 KB Output is correct
20 Correct 3 ms 10672 KB Output is correct
21 Correct 3 ms 10844 KB Output is correct
22 Correct 3 ms 10840 KB Output is correct
23 Correct 2 ms 10584 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
25 Correct 3 ms 10840 KB Output is correct
26 Correct 3 ms 10844 KB Output is correct
27 Correct 3 ms 10844 KB Output is correct
28 Correct 3 ms 10844 KB Output is correct
29 Correct 3 ms 10844 KB Output is correct
30 Correct 3 ms 10844 KB Output is correct
31 Correct 3 ms 10768 KB Output is correct
32 Correct 4 ms 11096 KB Output is correct
33 Correct 3 ms 10844 KB Output is correct
34 Correct 3 ms 10768 KB Output is correct
35 Correct 3 ms 10844 KB Output is correct
36 Correct 3 ms 10844 KB Output is correct
37 Correct 4 ms 10844 KB Output is correct
38 Correct 6 ms 10772 KB Output is correct
39 Correct 3 ms 10844 KB Output is correct
40 Correct 3 ms 10844 KB Output is correct
41 Correct 3 ms 10844 KB Output is correct
42 Correct 3 ms 10844 KB Output is correct
43 Correct 3 ms 10840 KB Output is correct
44 Correct 3 ms 10844 KB Output is correct
45 Correct 4 ms 10844 KB Output is correct
46 Correct 3 ms 10840 KB Output is correct
47 Correct 3 ms 10768 KB Output is correct
48 Correct 3 ms 10732 KB Output is correct
49 Correct 3 ms 10844 KB Output is correct
50 Correct 3 ms 10844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10844 KB Output is correct
2 Correct 4 ms 10844 KB Output is correct
3 Correct 4 ms 10844 KB Output is correct
4 Correct 3 ms 10844 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10840 KB Output is correct
7 Correct 4 ms 10588 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 4 ms 10840 KB Output is correct
11 Correct 3 ms 10840 KB Output is correct
12 Correct 4 ms 10844 KB Output is correct
13 Correct 3 ms 10840 KB Output is correct
14 Correct 3 ms 10844 KB Output is correct
15 Correct 2 ms 10724 KB Output is correct
16 Correct 2 ms 10588 KB Output is correct
17 Correct 4 ms 10844 KB Output is correct
18 Correct 3 ms 10844 KB Output is correct
19 Correct 3 ms 10840 KB Output is correct
20 Correct 3 ms 10672 KB Output is correct
21 Correct 3 ms 10844 KB Output is correct
22 Correct 3 ms 10840 KB Output is correct
23 Correct 2 ms 10584 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
25 Correct 59 ms 20532 KB Output is correct
26 Correct 62 ms 20584 KB Output is correct
27 Correct 65 ms 20648 KB Output is correct
28 Correct 60 ms 20676 KB Output is correct
29 Correct 40 ms 20808 KB Output is correct
30 Correct 40 ms 20676 KB Output is correct
31 Correct 6 ms 12124 KB Output is correct
32 Correct 6 ms 11708 KB Output is correct
33 Correct 7 ms 11868 KB Output is correct
34 Correct 5 ms 11864 KB Output is correct
35 Correct 73 ms 17252 KB Output is correct
36 Correct 71 ms 17312 KB Output is correct
37 Correct 68 ms 17236 KB Output is correct
38 Correct 63 ms 17484 KB Output is correct
39 Correct 42 ms 17488 KB Output is correct
40 Correct 42 ms 17216 KB Output is correct
41 Correct 7 ms 11352 KB Output is correct
42 Correct 5 ms 11356 KB Output is correct
43 Correct 62 ms 16908 KB Output is correct
44 Correct 81 ms 16836 KB Output is correct
45 Correct 65 ms 16944 KB Output is correct
46 Correct 76 ms 16924 KB Output is correct
47 Correct 48 ms 16996 KB Output is correct
48 Correct 39 ms 16844 KB Output is correct
49 Correct 6 ms 11352 KB Output is correct
50 Correct 5 ms 11356 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10844 KB Output is correct
2 Correct 4 ms 10844 KB Output is correct
3 Correct 4 ms 10844 KB Output is correct
4 Correct 3 ms 10844 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10840 KB Output is correct
7 Correct 4 ms 10588 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 4 ms 10840 KB Output is correct
11 Correct 3 ms 10840 KB Output is correct
12 Correct 4 ms 10844 KB Output is correct
13 Correct 3 ms 10840 KB Output is correct
14 Correct 3 ms 10844 KB Output is correct
15 Correct 2 ms 10724 KB Output is correct
16 Correct 2 ms 10588 KB Output is correct
17 Correct 4 ms 10844 KB Output is correct
18 Correct 3 ms 10844 KB Output is correct
19 Correct 3 ms 10840 KB Output is correct
20 Correct 3 ms 10672 KB Output is correct
21 Correct 3 ms 10844 KB Output is correct
22 Correct 3 ms 10840 KB Output is correct
23 Correct 2 ms 10584 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
25 Correct 59 ms 20532 KB Output is correct
26 Correct 62 ms 20584 KB Output is correct
27 Correct 65 ms 20648 KB Output is correct
28 Correct 60 ms 20676 KB Output is correct
29 Correct 40 ms 20808 KB Output is correct
30 Correct 40 ms 20676 KB Output is correct
31 Correct 6 ms 12124 KB Output is correct
32 Correct 6 ms 11708 KB Output is correct
33 Correct 7 ms 11868 KB Output is correct
34 Correct 5 ms 11864 KB Output is correct
35 Correct 73 ms 17252 KB Output is correct
36 Correct 71 ms 17312 KB Output is correct
37 Correct 68 ms 17236 KB Output is correct
38 Correct 63 ms 17484 KB Output is correct
39 Correct 42 ms 17488 KB Output is correct
40 Correct 42 ms 17216 KB Output is correct
41 Correct 7 ms 11352 KB Output is correct
42 Correct 5 ms 11356 KB Output is correct
43 Correct 62 ms 16908 KB Output is correct
44 Correct 81 ms 16836 KB Output is correct
45 Correct 65 ms 16944 KB Output is correct
46 Correct 76 ms 16924 KB Output is correct
47 Correct 48 ms 16996 KB Output is correct
48 Correct 39 ms 16844 KB Output is correct
49 Correct 6 ms 11352 KB Output is correct
50 Correct 5 ms 11356 KB Output is correct
51 Correct 151 ms 30956 KB Output is correct
52 Correct 150 ms 30908 KB Output is correct
53 Correct 160 ms 31164 KB Output is correct
54 Correct 145 ms 31164 KB Output is correct
55 Correct 100 ms 31012 KB Output is correct
56 Correct 107 ms 30916 KB Output is correct
57 Correct 20 ms 17004 KB Output is correct
58 Correct 16 ms 16852 KB Output is correct
59 Correct 16 ms 16760 KB Output is correct
60 Correct 16 ms 16848 KB Output is correct
61 Correct 173 ms 22596 KB Output is correct
62 Correct 172 ms 22820 KB Output is correct
63 Correct 172 ms 22724 KB Output is correct
64 Correct 182 ms 22844 KB Output is correct
65 Correct 127 ms 22732 KB Output is correct
66 Correct 104 ms 22388 KB Output is correct
67 Correct 17 ms 15056 KB Output is correct
68 Correct 20 ms 15196 KB Output is correct
69 Correct 229 ms 21556 KB Output is correct
70 Correct 204 ms 21564 KB Output is correct
71 Correct 177 ms 21860 KB Output is correct
72 Correct 176 ms 21696 KB Output is correct
73 Correct 134 ms 21312 KB Output is correct
74 Correct 139 ms 21596 KB Output is correct
75 Correct 18 ms 14808 KB Output is correct
76 Correct 17 ms 14808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 10844 KB Output is correct
2 Correct 4 ms 10844 KB Output is correct
3 Correct 4 ms 10844 KB Output is correct
4 Correct 3 ms 10844 KB Output is correct
5 Correct 4 ms 10844 KB Output is correct
6 Correct 4 ms 10840 KB Output is correct
7 Correct 4 ms 10588 KB Output is correct
8 Correct 2 ms 10588 KB Output is correct
9 Correct 3 ms 10844 KB Output is correct
10 Correct 4 ms 10840 KB Output is correct
11 Correct 3 ms 10840 KB Output is correct
12 Correct 4 ms 10844 KB Output is correct
13 Correct 3 ms 10840 KB Output is correct
14 Correct 3 ms 10844 KB Output is correct
15 Correct 2 ms 10724 KB Output is correct
16 Correct 2 ms 10588 KB Output is correct
17 Correct 4 ms 10844 KB Output is correct
18 Correct 3 ms 10844 KB Output is correct
19 Correct 3 ms 10840 KB Output is correct
20 Correct 3 ms 10672 KB Output is correct
21 Correct 3 ms 10844 KB Output is correct
22 Correct 3 ms 10840 KB Output is correct
23 Correct 2 ms 10584 KB Output is correct
24 Correct 2 ms 10588 KB Output is correct
25 Correct 3 ms 10840 KB Output is correct
26 Correct 3 ms 10844 KB Output is correct
27 Correct 3 ms 10844 KB Output is correct
28 Correct 3 ms 10844 KB Output is correct
29 Correct 3 ms 10844 KB Output is correct
30 Correct 3 ms 10844 KB Output is correct
31 Correct 3 ms 10768 KB Output is correct
32 Correct 4 ms 11096 KB Output is correct
33 Correct 3 ms 10844 KB Output is correct
34 Correct 3 ms 10768 KB Output is correct
35 Correct 3 ms 10844 KB Output is correct
36 Correct 3 ms 10844 KB Output is correct
37 Correct 4 ms 10844 KB Output is correct
38 Correct 6 ms 10772 KB Output is correct
39 Correct 3 ms 10844 KB Output is correct
40 Correct 3 ms 10844 KB Output is correct
41 Correct 3 ms 10844 KB Output is correct
42 Correct 3 ms 10844 KB Output is correct
43 Correct 3 ms 10840 KB Output is correct
44 Correct 3 ms 10844 KB Output is correct
45 Correct 4 ms 10844 KB Output is correct
46 Correct 3 ms 10840 KB Output is correct
47 Correct 3 ms 10768 KB Output is correct
48 Correct 3 ms 10732 KB Output is correct
49 Correct 3 ms 10844 KB Output is correct
50 Correct 3 ms 10844 KB Output is correct
51 Correct 59 ms 20532 KB Output is correct
52 Correct 62 ms 20584 KB Output is correct
53 Correct 65 ms 20648 KB Output is correct
54 Correct 60 ms 20676 KB Output is correct
55 Correct 40 ms 20808 KB Output is correct
56 Correct 40 ms 20676 KB Output is correct
57 Correct 6 ms 12124 KB Output is correct
58 Correct 6 ms 11708 KB Output is correct
59 Correct 7 ms 11868 KB Output is correct
60 Correct 5 ms 11864 KB Output is correct
61 Correct 73 ms 17252 KB Output is correct
62 Correct 71 ms 17312 KB Output is correct
63 Correct 68 ms 17236 KB Output is correct
64 Correct 63 ms 17484 KB Output is correct
65 Correct 42 ms 17488 KB Output is correct
66 Correct 42 ms 17216 KB Output is correct
67 Correct 7 ms 11352 KB Output is correct
68 Correct 5 ms 11356 KB Output is correct
69 Correct 62 ms 16908 KB Output is correct
70 Correct 81 ms 16836 KB Output is correct
71 Correct 65 ms 16944 KB Output is correct
72 Correct 76 ms 16924 KB Output is correct
73 Correct 48 ms 16996 KB Output is correct
74 Correct 39 ms 16844 KB Output is correct
75 Correct 6 ms 11352 KB Output is correct
76 Correct 5 ms 11356 KB Output is correct
77 Correct 151 ms 30956 KB Output is correct
78 Correct 150 ms 30908 KB Output is correct
79 Correct 160 ms 31164 KB Output is correct
80 Correct 145 ms 31164 KB Output is correct
81 Correct 100 ms 31012 KB Output is correct
82 Correct 107 ms 30916 KB Output is correct
83 Correct 20 ms 17004 KB Output is correct
84 Correct 16 ms 16852 KB Output is correct
85 Correct 16 ms 16760 KB Output is correct
86 Correct 16 ms 16848 KB Output is correct
87 Correct 173 ms 22596 KB Output is correct
88 Correct 172 ms 22820 KB Output is correct
89 Correct 172 ms 22724 KB Output is correct
90 Correct 182 ms 22844 KB Output is correct
91 Correct 127 ms 22732 KB Output is correct
92 Correct 104 ms 22388 KB Output is correct
93 Correct 17 ms 15056 KB Output is correct
94 Correct 20 ms 15196 KB Output is correct
95 Correct 229 ms 21556 KB Output is correct
96 Correct 204 ms 21564 KB Output is correct
97 Correct 177 ms 21860 KB Output is correct
98 Correct 176 ms 21696 KB Output is correct
99 Correct 134 ms 21312 KB Output is correct
100 Correct 139 ms 21596 KB Output is correct
101 Correct 18 ms 14808 KB Output is correct
102 Correct 17 ms 14808 KB Output is correct
103 Correct 154 ms 32232 KB Output is correct
104 Correct 158 ms 31740 KB Output is correct
105 Correct 159 ms 32264 KB Output is correct
106 Correct 145 ms 32168 KB Output is correct
107 Correct 118 ms 31796 KB Output is correct
108 Correct 98 ms 31680 KB Output is correct
109 Correct 16 ms 16852 KB Output is correct
110 Correct 19 ms 16852 KB Output is correct
111 Correct 17 ms 16852 KB Output is correct
112 Correct 18 ms 17020 KB Output is correct
113 Correct 205 ms 23744 KB Output is correct
114 Correct 172 ms 23584 KB Output is correct
115 Correct 162 ms 24024 KB Output is correct
116 Correct 154 ms 24260 KB Output is correct
117 Correct 104 ms 23488 KB Output is correct
118 Correct 105 ms 23192 KB Output is correct
119 Correct 22 ms 15316 KB Output is correct
120 Correct 22 ms 15316 KB Output is correct
121 Correct 174 ms 22220 KB Output is correct
122 Correct 174 ms 22208 KB Output is correct
123 Correct 162 ms 22972 KB Output is correct
124 Correct 171 ms 22884 KB Output is correct
125 Correct 114 ms 22012 KB Output is correct
126 Correct 114 ms 22064 KB Output is correct
127 Correct 18 ms 15052 KB Output is correct
128 Correct 20 ms 15196 KB Output is correct