CSES - Aalto Competitive Programming 2024 - wk2 - Wed - Results
Submission details
Task:Astralis session I
Sender:aalto2024b_003
Submission time:2024-09-11 17:14:03 +0300
Language:C++20
Status:READY
Result:
Test results
testverdicttime
#10.01 sdetails
#20.01 sdetails
#30.01 sdetails
#40.01 sdetails
#50.01 sdetails
#60.01 sdetails
#70.01 sdetails
#80.01 sdetails
#90.01 sdetails
#100.01 sdetails
#110.01 sdetails
#120.01 sdetails
#130.01 sdetails
#140.01 sdetails
#150.01 sdetails
#160.01 sdetails
#170.01 sdetails
#180.01 sdetails
#190.01 sdetails
#200.01 sdetails
#210.01 sdetails
#220.01 sdetails
#230.01 sdetails
#240.01 sdetails
#250.01 sdetails
#260.01 sdetails
#270.01 sdetails
#280.01 sdetails
#290.01 sdetails
#300.01 sdetails
#310.01 sdetails
#320.01 sdetails
#330.01 sdetails
#340.01 sdetails
#350.01 sdetails
#360.01 sdetails
#370.01 sdetails
#380.01 sdetails
#390.01 sdetails
#400.01 sdetails
#410.01 sdetails
#420.01 sdetails
#430.01 sdetails
#440.01 sdetails
#450.01 sdetails
#460.01 sdetails
#470.01 sdetails
#480.01 sdetails
#490.01 sdetails
#500.01 sdetails
#510.01 sdetails
#520.06 sdetails
#530.06 sdetails
#540.06 sdetails
#550.06 sdetails
#560.07 sdetails
#570.06 sdetails
#580.06 sdetails
#590.06 sdetails
#600.06 sdetails
#610.07 sdetails

Code

#include <bits/stdc++.h>
using namespace std;
#define int long long

string to_string(string s) {
    return '"' + s + '"';
}
 
string to_string(const char* s) {
    return to_string((string) s);
}
 
string to_string(bool b) {
    return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
    return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
    bool first = true;
    string res = "{";
    for (const auto &x : v) {
        if (!first) {
            res += ", ";
        }
        first = false;
        res += to_string(x);
    }
    res += "}";
    return res;
}
 
void debug_out() {
    cerr << endl;
}
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

const int N = 2e5 + 5;

int n;
vector<int> adj[N];
int sz[N];
int ans[N];

void rec(int u, int p) {
    ans[u] = 1;
    for (int v : adj[u]) {
        if (v == p) continue;
        rec(v, u);
    }
}

void dfs(int u, int p = -1) {
    sz[u] = 1;
    for (int v : adj[u]) {
        if (v == p) continue;
        dfs(v, u);
        sz[u] += sz[v];
    }
    if (sz[u] == n / 2) {
        // ok
        cout << "YES\n";
        rec(u, p);
        for (int i = 1; i <= n; i++) {
            if (ans[i]) cout << "U";
            else cout << "M";
        }
        cout << '\n';
        exit(0);
    }
}

signed main() {
    cin.tie(0)->sync_with_stdio(0);

    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v;
        cin >> u >> v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }    

    dfs(1);
    cout << "NO\n";
}

Test details

Test 1

Verdict:

input
2
1 2

correct output
Yes
MU

user output
YES
MU

Test 2

Verdict:

input
6
1 3
2 3
2 6
4 6
...

correct output
No

user output
NO

Test 3

Verdict:

input
6
1 2
2 3
3 6
2 4
...

correct output
No

user output
NO

Test 4

Verdict:

input
6
1 6
1 4
2 4
2 3
...

correct output
No

user output
NO

Test 5

Verdict:

input
6
2 4
1 4
2 6
1 3
...

correct output
Yes
MUMUMU

user output
YES
MUMUMU

Test 6

Verdict:

input
8
1 8
5 8
3 5
3 6
...

correct output
Yes
MUMUMUUM

user output
YES
MUMUMUUM

Test 7

Verdict:

input
8
1 4
1 6
3 6
1 5
...

correct output
Yes
MUUMMUMU

user output
YES
MUUMMUMU

Test 8

Verdict:

input
8
1 7
1 3
1 8
2 8
...

correct output
No

user output
NO

Test 9

Verdict:

input
8
2 3
3 8
7 8
5 8
...

correct output
Yes
MMUMUMUU

user output
YES
MMUMUMUU

Test 10

Verdict:

input
10
4 8
4 7
1 7
3 4
...

correct output
Yes
MUMMMUMUUU

user output
YES
MUMMMUMUUU

Test 11

Verdict:

input
10
3 4
4 5
4 8
4 10
...

correct output
No

user output
NO

Test 12

Verdict:

input
10
1 3
2 3
2 6
6 10
...

correct output
Yes
MMMUUMUMUU

user output
YES
MMMUUMUMUU

Test 13

Verdict:

input
10
1 10
1 3
6 10
8 10
...

correct output
No

user output
NO

Test 14

Verdict:

input
10
1 6
1 4
2 4
2 9
...

correct output
No

user output
NO

Test 15

Verdict:

input
12
4 10
4 11
9 11
6 11
...

correct output
Yes
UUUMUMMUMUMM

user output
YES
MMMUMUUMUMUU

Test 16

Verdict:

input
12
1 2
1 8
5 8
3 8
...

correct output
Yes
MUMMMUUMUUUM

user output
YES
MUMMMUUMUUUM

Test 17

Verdict:

input
14
9 12
6 9
3 6
3 11
...

correct output
No

user output
NO

Test 18

Verdict:

input
14
13 14
7 13
3 7
7 10
...

correct output
Yes
UMMMMUMUUMUUMU

user output
YES
MUUUUMUMMUMMUM

Test 19

Verdict:

input
14
1 3
3 8
3 7
8 9
...

correct output
Yes
MUUUMMUUUMMMMU

user output
YES
MUUUMMUUUMMMMU

Test 20

Verdict:

input
16
4 12
1 4
12 16
11 12
...

correct output
No

user output
NO

Test 21

Verdict:

input
18
12 13
13 17
8 13
12 15
...

correct output
No

user output
NO

Test 22

Verdict:

input
100
24 28
28 65
28 58
54 65
...

correct output
Yes
MMUUMUMMUMUMUUMUUMMUUUMMMUUUUM...

user output
YES
MMUUMUMMUMUMUUMUUMMUUUMMMUUUUM...

Test 23

Verdict:

input
100
57 98
24 57
24 34
25 34
...

correct output
Yes
MUUMUMUUUMMUMMUMUMMMMMUUUMUUMM...

user output
YES
MUUMUMUUUMMUMMUMUMMMMMUUUMUUMM...

Test 24

Verdict:

input
100
6 41
6 20
6 18
6 88
...

correct output
Yes
MMMMUMMMUMUUMMUUUMMMUUUUUMUUUU...

user output
YES
MMMMUMMMUMUUMMUUUMMMUUUUUMUUUU...

Test 25

Verdict:

input
100
24 100
92 100
62 100
88 100
...

correct output
Yes
MUUMMUUMMUMUMUMUUUUUUMMMUMUMUM...

user output
YES
MUUMMUUMMUMUMUMUUUUUUMMMUMUMUM...

Test 26

Verdict:

input
100
65 83
68 83
65 87
21 65
...

correct output
No

user output
NO

Test 27

Verdict:

input
100
12 87
12 56
41 56
11 41
...

correct output
No

user output
NO

Test 28

Verdict:

input
100
13 29
13 38
13 34
10 13
...

correct output
Yes
MMMMUUMUMMUUMMUUMMMUMMUUMMUUUU...

user output
YES
MMMMUUMUMMUUMMUUMMMUMMUUMMUUUU...

Test 29

Verdict:

input
100
77 94
52 77
53 77
53 56
...

correct output
No

user output
NO

Test 30

Verdict:

input
100
56 59
56 76
17 76
17 75
...

correct output
No

user output
NO

Test 31

Verdict:

input
100
19 70
70 86
27 86
27 31
...

correct output
Yes
MMMMUMMUMMUUMMUMUUUMMMUMUMUUMU...

user output
YES
MMMMUMMUMMUUMMUMUUUMMMUMUMUUMU...

Test 32

Verdict:

input
200
28 148
28 122
28 137
122 178
...

correct output
Yes
UUMUMMMUUMMUMMMUMMUUMUMUMUMMMU...

user output
YES
MMUMUUUMMUUMUUUMUUMMUMUMUMUUUM...

Test 33

Verdict:

input
200
57 98
57 153
34 153
98 109
...

correct output
No

user output
NO

Test 34

Verdict:

input
200
6 177
6 20
6 158
88 158
...

correct output
Yes
MUUMUMMMUMUUMUUUUUUMUMMMMUUMMU...

user output
YES
MUUMUMMMUMUUMUUUUUUMUMMMMUUMMU...

Test 35

Verdict:

input
200
142 178
119 142
142 155
119 140
...

correct output
No

user output
NO

Test 36

Verdict:

input
200
83 150
68 83
68 158
135 158
...

correct output
Yes
MMMUUUUUUMUUUMUMUUMMMUMUUUMMUM...

user output
YES
MMMUUUUUUMUUUMUMUUMMMUMUUUMMUM...

Test 37

Verdict:

input
200
20 177
87 177
121 177
137 177
...

correct output
Yes
MMUMUMMMUUUMUMUMMMUMUMUUUUUUMM...

user output
YES
MMUMUMMMUUUMUMUMMMUMUMUUUUUUMM...

Test 38

Verdict:

input
200
13 139
13 38
13 34
10 38
...

correct output
Yes
MUMMUUMUUMUUMMUMMMMUMMUMUUUMMU...

user output
YES
MUMMUUMUUMUUMMUMMMMUMMUMUUUMMU...

Test 39

Verdict:

input
200
84 198
77 198
52 198
53 77
...

correct output
Yes
MMMUMUMMMUUUUMUUUMMMMMUMUMUUUU...

user output
YES
MMMUMUMMMUUUUMUUUMMMMMUMUMUUUU...

Test 40

Verdict:

input
200
56 112
76 112
56 182
56 114
...

correct output
No

user output
NO

Test 41

Verdict:

input
200
19 114
19 70
70 86
19 27
...

correct output
Yes
MMMUMUUUUUMUMMMMMMMUUMMUMMMMUM...

user output
YES
MMMUMUUUUUMUMMMMMMMUUMMUMMMMUM...

Test 42

Verdict:

input
1000
811 883
397 883
137 397
546 883
...

correct output
Yes
MMMMMUUMUMUUUUUUMUMUMMMMUMMUMM...

user output
YES
MMMMMUUMUMUUUUUUMUMUMMMMUMMUMM...

Test 43

Verdict:

input
1000
393 736
393 398
398 407
351 393
...

correct output
No

user output
NO

Test 44

Verdict:

input
1000
507 955
340 955
507 813
418 955
...

correct output
No

user output
NO

Test 45

Verdict:

input
1000
230 974
230 440
440 752
752 977
...

correct output
No

user output
NO

Test 46

Verdict:

input
1000
406 944
778 944
68 944
545 778
...

correct output
Yes
UMUMMUMUUMUUMUUMUMMUUMUUMUUUUM...

user output
YES
MUMUUMUMMUMMUMMUMUUMMUMMUMMMMU...

Test 47

Verdict:

input
1000
771 921
368 921
121 921
121 810
...

correct output
Yes
UMMUUUUUMUMMUMUMUUUUMMMMUMUUMM...

user output
YES
MUUMMMMMUMUUMUMUMMMMUUUUMUMMUU...

Test 48

Verdict:

input
1000
290 518
518 738
518 554
290 997
...

correct output
No

user output
NO

Test 49

Verdict:

input
1000
370 791
390 791
390 835
585 835
...

correct output
Yes
MMUUUUUMMMUMMUMMMMMMUUMMUMMMMU...

user output
YES
MMUUUUUMMMUMMUMMMMMMUUMMUMMMMU...

Test 50

Verdict:

input
1000
111 804
778 804
520 804
520 829
...

correct output
Yes
MMMUMUUUUUMMMUMMMMMUUMMUMMUUUU...

user output
YES
MMMUMUUUUUMMMUMMMMMUUMMUMMUUUU...

Test 51

Verdict:

input
1000
627 823
399 627
27 399
27 945
...

correct output
Yes
MMUMMMMUUMMUUMUUUUUMUMMUMMMMMU...

user output
YES
MMUMMMMUUMMUUMUUUUUMUMMUMMMMMU...

Test 52

Verdict:

input
100000
26991 68205
21905 68205
3029 26991
21905 29288
...

correct output
No

user output
NO

Test 53

Verdict:

input
100000
41845 94618
94618 96640
65841 94618
9894 96640
...

correct output
Yes
UMUUUMMUUUMMUMMUMUMMMUMMMUMUMU...

user output
YES
MUMMMUUMMMUUMUUMUMUUUMUUUMUMUM...

Test 54

Verdict:

input
100000
11081 29940
11081 90273
11081 56653
56653 73314
...

correct output
Yes
UMMUUMMMUUMMMMMUUMMUUUMUMMMUUU...

user output
YES
MUUMMUUUMMUUUUUMMUUMMMUMUUUMMM...

Test 55

Verdict:

input
100000
27549 31873
27549 48777
48777 71940
48777 59266
...

correct output
Yes
MMMMUUMUUMUMUMMUUUMMUMMMUMUUUM...

user output
YES
MMMMUUMUUMUMUMMUUUMMUMMMUMUUUM...

Test 56

Verdict:

input
100000
2460 57807
2460 59927
56550 59927
35046 56550
...

correct output
Yes
MMMUUMMUMMUUUMMUMUMMMUMUUMUMUM...

user output
YES
MMMUUMMUMMUUUMMUMUMMMUMUUMUMUM...

Test 57

Verdict:

input
100000
13089 77222
77222 89616
36711 89616
27645 77222
...

correct output
Yes
UMUUUMMMUUUUMMUMMMUUMMUUMUMUMU...

user output
YES
MUMMMUUUMMMMUUMUUUMMUUMMUMUMUM...

Test 58

Verdict:

input
100000
35805 70440
70440 82302
64483 82302
64483 96767
...

correct output
Yes
MMMUUMMMUUUMMMUUMUUMUMMUUUMUUM...

user output
YES
MMMUUMMMUUUMMMUUMUUMUMMUUUMUUM...

Test 59

Verdict:

input
100000
16206 68738
37820 68738
55519 68738
55519 77758
...

correct output
Yes
MMUUUMUUMUUMUUMUMMMMMUMUUUUUUU...

user output
YES
MMUUUMUUMUUMUUMUMMMMMUMUUUUUUU...

Test 60

Verdict:

input
100000
47137 86808
47137 80136
47137 73346
73346 78144
...

correct output
Yes
UUMUMMUUUUMMMMMMMMUUMMMMMMUUMU...

user output
YES
MMUMUUMMMMUUUUUUUUMMUUUUUUMMUM...

Test 61

Verdict:

input
100000
39438 53660
53660 60245
20924 60245
20924 38669
...

correct output
No

user output
NO