QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#845415#9525. Welcome to Join the Online Meeting!xiezheyuanWA 114ms47036kbC++141.7kb2025-01-06 16:36:082025-01-06 16:36:13

Judging History

This is the latest submission verdict.

  • [2025-01-06 16:36:13]
  • Judged
  • Verdict: WA
  • Time: 114ms
  • Memory: 47036kb
  • [2025-01-06 16:36:08]
  • Submitted

answer

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

const int N = 2e5 + 5, M = 5e5 + 5;
int n, m, k, fa[N];
bool busy[N], called[N];

int find(int x){
    return fa[x] == x ? x : fa[x] = find(fa[x]);
}

vector<int> t[N];

void add(int x, int y){ t[x].push_back(y), t[y].push_back(x); }

vector<vector<int> > opts;

void dfs(int u, int fa){
    t[u].erase(find(t[u].begin(), t[u].end(), fa));
    if(t[u].empty()) return;
    vector<int> vct = t[u];
    vct.insert(vct.begin(), vct.size());
    vct.insert(vct.begin(), u);
    opts.push_back(vct);
    for(int v : t[u]) dfs(v, u);
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    cin >> n >> m >> k;
    for(int i=1,t;i<=k;i++) cin >> t, busy[t] = 1;
    for(int i=1;i<=n;i++){
        if(!busy[i]) called[i] = true;
    }
    iota(fa + 1, fa + n + 1, 1);
    for(int i=1;i<=m;i++){
        int u, v; cin >> u >> v;
        if(!called[u] && !called[v]) continue;
        if(!(busy[u] || busy[v])){
            if(find(u) != find(v)) fa[find(u)] = find(v), add(u, v);
            continue;
        }
        if(busy[u]){
            if(!called[u]) add(u, v), called[u] = 1;
        }
        else{
            if(!called[v]) add(u, v), called[v] = 1;
        }
    }
    for(int i=1;i<=n;i++){
        if((busy[i] && !called[i]) || (!busy[i] && (find(i) != find(1)))) return (cout << "No\n"), 0;
    }
    cout << "Yes\n";
    int rt = 0;
    for(int i=1;i<=n;i++){
        if(!busy[i]){ rt = i; break; }
    }
    t[rt].push_back(0);
    dfs(rt, 0);
    cout << opts.size() << '\n';
    for(auto i : opts){
        for(int j : i) cout << j << ' ';
        cout << '\n';
    }
    return 0;
}

// Written by xiezheyuan

詳細信息

Test #1:

score: 100
Accepted
time: 0ms
memory: 8284kb

input:

4 5 2
3 4
1 2
1 3
2 3
3 4
2 4

output:

Yes
2
1 2 2 3 
2 1 4 

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 8320kb

input:

4 5 3
2 4 3
1 2
1 3
2 3
3 4
2 4

output:

No

result:

ok ok

Test #3:

score: 0
Accepted
time: 0ms
memory: 8884kb

input:

4 6 2
3 4
1 3
1 4
2 3
2 4
1 2
3 4

output:

Yes
1
1 3 3 4 2 

result:

ok ok

Test #4:

score: 0
Accepted
time: 0ms
memory: 8712kb

input:

6 6 0

1 2
2 3
3 1
4 5
5 6
6 4

output:

No

result:

ok ok

Test #5:

score: 0
Accepted
time: 110ms
memory: 47036kb

input:

200000 199999 2
142330 49798
49798 116486
116486 64386
64386 192793
192793 61212
61212 138489
138489 83788
83788 89573
89573 8596
8596 156548
156548 41800
41800 14478
14478 27908
27908 82806
82806 9353
9353 160166
160166 92308
92308 36265
36265 126943
126943 190578
190578 191148
191148 177381
177381...

output:

Yes
199998
1 2 95113 178679 
95113 1 27292 
27292 1 93394 
93394 1 30051 
30051 1 174891 
174891 1 165580 
165580 1 94294 
94294 1 123410 
123410 1 55130 
55130 1 154872 
154872 1 166138 
166138 1 30681 
30681 1 51031 
51031 1 89161 
89161 1 187764 
187764 1 14291 
14291 1 66035 
66035 1 83781 
8378...

result:

ok ok

Test #6:

score: 0
Accepted
time: 112ms
memory: 44032kb

input:

199999 199998 1
136702
159826 166341
166341 59559
59559 169672
169672 102084
102084 136269
136269 57057
57057 59116
59116 119963
119963 85663
85663 33942
33942 84604
84604 189395
189395 154906
154906 22175
22175 144902
144902 198523
198523 35993
35993 35690
35690 47504
47504 104458
104458 68253
6825...

output:

Yes
199997
1 2 172082 191801 
172082 1 188910 
188910 1 131169 
131169 1 48799 
48799 1 20862 
20862 1 189938 
189938 1 46325 
46325 1 48691 
48691 1 45299 
45299 1 166683 
166683 1 155350 
155350 1 88290 
88290 1 140962 
140962 1 106716 
106716 1 180949 
180949 1 116565 
116565 1 41562 
41562 1 528...

result:

ok ok

Test #7:

score: 0
Accepted
time: 114ms
memory: 44780kb

input:

199998 199997 0

67665 130538
130538 101337
101337 73749
73749 138128
138128 1274
1274 108069
108069 50961
50961 7039
7039 109946
109946 170551
170551 193330
193330 113590
113590 92775
92775 2146
2146 43591
43591 125033
125033 75583
75583 173991
173991 46820
46820 3986
3986 163272
163272 91657
91657...

output:

Yes
199996
1 2 5661 102870 
5661 1 114962 
114962 1 36222 
36222 1 92959 
92959 1 66511 
66511 1 81220 
81220 1 182229 
182229 1 7906 
7906 1 81750 
81750 1 75132 
75132 1 188940 
188940 1 144653 
144653 1 76023 
76023 1 120474 
120474 1 155713 
155713 1 152446 
152446 1 26414 
26414 1 110040 
11004...

result:

ok ok

Test #8:

score: 0
Accepted
time: 46ms
memory: 16132kb

input:

199997 199996 1
158877
35837 79489
79489 72932
72932 14238
14238 73007
73007 66909
66909 49015
49015 129581
129581 138449
138449 94774
94774 189625
189625 23578
23578 31043
31043 146625
146625 161587
161587 136966
136966 184859
184859 27587
27587 155616
155616 72392
72392 195320
195320 75551
75551 1...

output:

No

result:

ok ok

Test #9:

score: 0
Accepted
time: 22ms
memory: 9428kb

input:

200000 199999 1
29111
29111 80079
29111 131587
29111 197066
29111 125194
29111 156736
50697 29111
29111 74382
113595 29111
29111 26046
29111 172868
178564 29111
174875 29111
93471 29111
88216 29111
29111 147893
29111 145746
29111 34038
146500 29111
67862 29111
29111 19222
29111 121535
29111 49102
29...

output:

No

result:

ok ok

Test #10:

score: 0
Accepted
time: 49ms
memory: 18296kb

input:

199999 199998 2
52512 104330
130511 66864
139434 66864
92884 66864
66864 185580
184115 66864
137395 66864
66864 43463
118395 66864
111697 66864
66864 133237
66864 112507
66864 140264
66864 10
66864 151082
155779 66864
107988 66864
148839 66864
66864 40909
172685 66864
66864 189374
180054 66864
49 66...

output:

Yes
2
1 1 66864 
66864 199997 130511 139434 92884 185580 184115 137395 43463 118395 111697 133237 112507 140264 10 151082 155779 107988 148839 40909 172685 189374 180054 49 41830 19259 186287 41932 21357 66485 95229 126195 72801 154651 48615 111519 156500 156919 60203 11260 164641 168543 130264 3648...

result:

ok ok

Test #11:

score: 0
Accepted
time: 37ms
memory: 17960kb

input:

199998 199997 0

77056 67665
130538 77056
77056 101337
73749 77056
77056 138128
1274 77056
77056 108069
50961 77056
77056 7039
77056 109946
77056 170551
193330 77056
113590 77056
77056 92775
2146 77056
43591 77056
77056 125033
75583 77056
173991 77056
46820 77056
77056 3986
77056 163272
91657 77056
...

output:

Yes
2
1 1 77056 
77056 199996 67665 130538 101337 73749 138128 1274 108069 50961 7039 109946 170551 193330 113590 92775 2146 43591 125033 75583 173991 46820 3986 163272 91657 92212 191670 170218 149297 164182 6856 61891 95065 7257 47282 126716 84031 52189 32847 63118 134126 143246 30142 58215 3315 1...

result:

ok ok

Test #12:

score: -100
Wrong Answer
time: 36ms
memory: 8776kb

input:

1000 499500 999
458 720 932 821 847 788 447 593 430 896 257 238 380 924 968 30 389 306 278 824 83 342 329 513 476 313 714 348 602 105 758 777 663 1000 20 756 546 256 123 340 69 244 772 625 390 557 911 272 496 127 409 436 845 574 958 921 24 17 770 630 851 147 178 976 77 181 230 723 974 345 501 683 24...

output:

No

result:

wrong answer jury has found a solution, but participant hasn't