CSES - Datatähti 2024 loppu - Results
Submission details
Task:Polut
Sender:cppbetter
Submission time:2024-01-20 15:38:58 +0200
Language:C++20
Status:READY
Result:0
Feedback
groupverdictscore
#10
#20
#30
Test results
testverdicttimegroup
#1ACCEPTED0.00 s1, 2, 3details
#20.00 s1, 2, 3details
#30.00 s1, 2, 3details
#40.00 s1, 2, 3details
#50.00 s1, 2, 3details
#60.00 s1, 2, 3details
#7ACCEPTED0.00 s1, 2, 3details
#80.00 s1, 2, 3details
#90.00 s1, 2, 3details
#100.00 s1, 2, 3details
#110.00 s1, 2, 3details
#120.00 s2, 3details
#130.00 s2, 3details
#140.00 s2, 3details
#15ACCEPTED0.00 s2, 3details
#160.00 s2, 3details
#170.00 s2, 3details
#180.00 s3details
#190.00 s3details
#200.00 s3details
#21ACCEPTED0.00 s3details
#220.00 s3details
#230.00 s3details

Code

#include <bits/stdc++.h>

using namespace std;
using ll = int64_t;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    ll n, m;
    cin >> n >> m;

    unordered_set<ll> s;

    deque<ll> d1;
    deque<ll> d2;

    for(ll i = 0; i < m; i++) {
        ll a, b;
        cin >> a >> b;
        if(!d1.empty()) {
            if(d1.front() == b && s.find(a) == s.end()) {
                s.insert(a);
                d1.push_front(a);
                continue;
            }  
            if(d1.back() == a && s.find(b) == s.end()) {
                s.insert(b);
                d1.push_back(b);
                continue;
            } 
        }
        if(!d2.empty()) {
            if(d2.front() == b && s.find(a) == s.end()) {
                s.insert(a);
                d2.push_front(a);           
                continue;
            }
            if(d2.back() == a && s.find(b) == s.end()) {
                s.insert(b);
                d2.push_back(b);
                continue;
            }  
        }
        if (s.find(b) == s.end() && s.find(a) == s.end()) {
            if(d1.empty()) {
                d1 = { a, b };
                s.insert(a);
                s.insert(b);
                continue;
            }
            if(d2.empty()) {
                d2 = { a, b };
                s.insert(a);
                s.insert(b);
                continue;
            }
        }
        if (s.find(b) == s.end()) {
            if(d1.empty()) {
                d1 = { b };
                s.emplace(b);
                continue;
            }
            if(d2.empty()) {
                d2 = { b };
                s.emplace(b);
                continue;
            }
        }
        if (s.find(a) == s.end()) {
            if(d1.empty()) {
                d1 = { a };
                s.emplace(a);
                continue;
            }
            if(d2.empty()) {
                d2 = { a };
                s.emplace(a);
                continue;
            }
        }

        cout << "NO\n";
        return 0;
    }
    
    cout << "YES\n";
    cout << d1.size() << " ";
    for(auto e : d1)
        cout << e << " ";
    cout << "\n";
    cout << d2.size() << " ";
    for(auto e : d2)
        cout << e << " ";
    cout << "\n";

    return 0;
}

Test details

Test 1

Group: 1, 2, 3

Verdict: ACCEPTED

input
2 0

correct output
YES
1 2 
1 1 

user output
YES


Test 2

Group: 1, 2, 3

Verdict:

input
5 8
3 4
2 4
2 5
1 3
...

correct output
YES
2 2 5 
3 1 3 4 

user output
NO

Test 3

Group: 1, 2, 3

Verdict:

input
200 300
74 145
156 176
192 168
141 133
...

correct output
YES
87 200 136 117 13 169 22 187 1...

user output
NO

Test 4

Group: 1, 2, 3

Verdict:

input
200 500
37 119
47 10
17 31
130 28
...

correct output
YES
90 84 70 170 117 129 17 31 186...

user output
NO

Test 5

Group: 1, 2, 3

Verdict:

input
200 500
79 1
104 127
31 38
83 85
...

correct output
YES
7 70 186 22 171 36 40 135 
193 41 91 25 42 160 83 2 173 5...

user output
NO

Test 6

Group: 1, 2, 3

Verdict:

input
200 500
145 50
4 102
136 55
148 34
...

correct output
YES
109 70 125 78 128 170 126 184 ...

user output
NO

Test 7

Group: 1, 2, 3

Verdict: ACCEPTED

input
200 500
44 38
198 85
69 167
74 39
...

correct output
NO

user output
NO

Test 8

Group: 1, 2, 3

Verdict:

input
200 500
41 93
98 4
171 72
127 166
...

correct output
YES
88 76 116 195 197 82 42 130 46...

user output
NO

Test 9

Group: 1, 2, 3

Verdict:

input
192 494
17 148
82 57
100 152
38 102
...

correct output
YES
154 191 183 77 3 173 83 112 15...

user output
NO

Test 10

Group: 1, 2, 3

Verdict:

input
193 497
24 110
17 193
129 117
23 186
...

correct output
YES
24 156 123 30 189 95 34 5 96 1...

user output
NO

Test 11

Group: 1, 2, 3

Verdict:

input
194 500
57 158
23 40
31 50
189 121
...

correct output
YES
27 168 116 136 175 180 12 89 6...

user output
NO

Test 12

Group: 2, 3

Verdict:

input
10000 15000
8243 3033
3299 579
4920 2342
2816 7811
...

correct output
YES
9236 3099 5585 9185 7222 9342 ...

user output
NO

Test 13

Group: 2, 3

Verdict:

input
10000 20000
6246 3603
5105 3531
6953 4682
2625 3510
...

correct output
YES
8734 5847 7473 5388 4872 4557 ...

user output
NO

Test 14

Group: 2, 3

Verdict:

input
10000 20000
5853 1019
2465 2936
2022 3609
9429 4118
...

correct output
YES
5204 3987 6388 4732 4403 7869 ...

user output
NO

Test 15

Group: 2, 3

Verdict: ACCEPTED

input
10000 20000
3439 3806
9336 5210
7784 848
5162 9830
...

correct output
NO

user output
NO

Test 16

Group: 2, 3

Verdict:

input
10000 20000
8908 287
2525 6024
1851 844
72 6898
...

correct output
YES
2487 3806 7839 4969 2661 4199 ...

user output
NO

Test 17

Group: 2, 3

Verdict:

input
7621 19995
6223 473
4893 990
5326 3614
421 591
...

correct output
YES
6340 5076 2779 1201 7053 1720 ...

user output
NO

Test 18

Group: 3

Verdict:

input
200000 300000
17151 175317
68698 43101
190738 54240
105443 37722
...

correct output
YES
163946 182154 120966 26194 771...

user output
NO

Test 19

Group: 3

Verdict:

input
200000 500000
128290 197429
67543 48696
156347 40114
114481 197
...

correct output
YES
30833 112330 10351 23335 11682...

user output
NO

Test 20

Group: 3

Verdict:

input
200000 500000
93623 55553
60858 72598
15531 30650
196624 28459
...

correct output
YES
99923 156477 12892 147937 1060...

user output
NO

Test 21

Group: 3

Verdict: ACCEPTED

input
200000 500000
76457 8199
163450 19462
107840 24269
178642 128924
...

correct output
NO

user output
NO

Test 22

Group: 3

Verdict:

input
200000 500000
181062 44502
115318 176115
33437 57568
163325 17752
...

correct output
YES
141551 129409 52010 108449 242...

user output
NO

Test 23

Group: 3

Verdict:

input
190479 499998
113031 136485
5993 50604
19834 84581
39043 93744
...

correct output
YES
170843 113031 163271 166394 43...

user output
NO