QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#720734 | #9525. Welcome to Join the Online Meeting! | zzfs# | WA | 0ms | 3832kb | C++14 | 1.8kb | 2024-11-07 13:51:31 | 2024-11-07 13:51:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
void solve()
{
int n, m, k;
cin >> n >> m >> k;
vector<int> vis(n + 1, 0);
for (int i = 1; i <= k; i++)
{
int x;
cin >> x;
vis[x] = -1;
}
vector<vector<int>> g(n + 1);
for (int i = 0; i < m; i++)
{
int u, v;
cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
int cnt = 0;
vector<pair<int, vector<int>>> ans;
auto bfs = [&](int s)
{
queue<int> q;
q.push(s);
vis[s] = 1;
cnt++;
while (!q.empty())
{
int u = q.front();
q.pop();
vector<int> tmp;
for (auto v : g[u])
{
if (vis[v] == -1)
{
vis[v] = 1;
cnt++;
tmp.push_back(v);
}
if (vis[v] == 0)
{
vis[v] = 1;
cnt++;
tmp.push_back(v);
q.push(v);
}
}
ans.push_back({u, tmp});
}
};
for (int i = 1; i <= n; i++)
{
if (vis[i] != -1)
{
bfs(i);
break;
}
}
if (cnt != n)
{
cout << "No" << '\n';
return;
}
cout << "Yes" << '\n';
cout << ans.size() << '\n';
for (auto [x, v] : ans)
{
cout << x << ' ' << v.size();
for (auto y : v)
cout << ' ' << y;
cout << '\n';
}
}
signed main()
{
cin.tie(0)->ios::sync_with_stdio(false);
int t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3556kb
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: 3832kb
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: -100
Wrong Answer
time: 0ms
memory: 3816kb
input:
4 6 2 3 4 1 3 1 4 2 3 2 4 1 2 3 4
output:
Yes 2 1 3 3 4 2 2 0
result:
wrong answer Integer parameter [name=y_j] equals to 0, violates the range [1, 4]