QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#714085#9525. Welcome to Join the Online Meeting!guanghereWA 88ms36992kbC++232.0kb2024-11-05 21:36:142024-11-05 21:36:14

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 21:36:14]
  • 评测
  • 测评结果:WA
  • 用时:88ms
  • 内存:36992kb
  • [2024-11-05 21:36:14]
  • 提交

answer

//
// Created by 24087 on 24-11-5.
//
#include <iostream>
#include <numeric>
#include <vector>

int n, m, k;
std::vector<std::vector<int>> g;

std::vector<std::vector<int>> tmp;
std::vector<bool> vis;
void dfs(int now, int dep) {
    vis[now] = true;
    for(auto &v : g[now]) {
        if(vis[v])
            continue;
        tmp[now].push_back(v);
        dfs(v, dep + 1);
    }
}

int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

    std::cin >> n >> m >> k;

    g.resize(n + 1);//u->v表示u能够邀请v
    tmp.resize(n + 1);
    vis.resize(n + 1);

    std::vector<bool> busy(n + 1);
    for(int i = 1, pos; i <= k; i++) {
        std::cin >> pos;
        busy[pos] = true;
    }//如果busy[i]为true,g[i] = {}

    for(int i = 1, u, v; i <= m; i++) {
        std::cin >> u >> v;
        if(!busy[u]) {
            g[u].push_back(v);
        }
        if(!busy[v]) {
            g[v].push_back(u);
        }
    }
    for(int i = 1; i <= n; i++) {
        if(busy[i]) {
            continue;
        }
        dfs(i, 1);
        if(std::accumulate(vis.begin(), vis.end(), 0) == n) {
            std::cout << "Yes\n" << std::accumulate(tmp.begin(), tmp.end(), 0, [](int sum, const std::vector<int> &v) {
                return sum + !v.empty();
            }) << '\n' << i << ' ' << tmp[i].size() << ' ';

            for(auto &v : tmp[i]) {
                std::cout << v << ' ';
            }
            std::cout << '\n';

            for(int j = 1; j <= n; j++) {
                if(!tmp[j].empty() && j != i) {
                    std::cout << j << ' ' << tmp[j].size() << ' ';
                    for(auto &v : tmp[j]) {
                        std::cout << v << ' ';
                    }
                    std::cout << '\n';
                }
            }

            return 0;
        }
        tmp.assign(n + 1, std::vector<int>());
        vis.assign(n + 1, false);
    }
    std::cout << "No\n";
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

Yes
2
1 1 2 
2 2 3 4 

result:

ok ok

Test #2:

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

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: 3812kb

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: 3612kb

input:

6 6 0

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

output:

No

result:

ok ok

Test #5:

score: -100
Wrong Answer
time: 88ms
memory: 36992kb

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 
2 1 198122 
3 1 41738 
4 1 196324 
5 1 91673 
6 1 796 
7 1 136018 
8 1 100182 
9 1 101606 
10 1 73864 
11 1 105951 
12 1 63827 
13 1 130553 
14 1 177897 
15 1 196567 
16 1 92389 
17 1 72182 
18 1 141202 
19 1 45379 
20 1 114057 
21 1 105287 
22 1 7260 
23 1 40268 
24 1 5...

result:

wrong answer on step #2, member 2 is not invited before inviting others