QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#884408 | #9525. Welcome to Join the Online Meeting! | 1903331632 | WA | 1ms | 5728kb | C++23 | 2.4kb | 2025-02-06 04:32:29 | 2025-02-06 04:32:30 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1e6 + 10;
#define pii pair<int, int>
#define lowbit(x) (x & (-x))
const int mod = 1e9 + 7;
int n, m, k;
bool st[N];
bool vis[N];
vector<int> e[N];
void solve()
{
cin >> n >> m >> k;
for (int i = 0; i < k; i++)
{
int x;
cin >> x;
st[x] = 1;
}
for (int i = 0; i < m; i++)
{
int a, b;
cin >> a >> b;
e[a].push_back(b);
e[b].push_back(a);
}
for (int i = 1; i <= n; i++)
{
if (st[i])
continue;
queue<int> q;
q.push(i);
vis[i] = 1;
while (!q.empty())
{
int u = q.front();
q.pop();
if (!st[i])
for (auto v : e[u])
{
if (vis[v])
continue;
q.push(v);
vis[v] = 1;
}
}
}
for (int i = 1; i <= n; i++)
{
if (vis[i] == 0)
{
cout << "No" << endl;
return;
}
}
vector<vector<int>> res;
for (int i = 1; i <= n; i++)
{
if (st[i] == 0)
{
for (int j = 1; j <= n; j++)
vis[j] = 0;
queue<int> q;
q.push(i);
vis[i] = 1;
while (!q.empty())
{
int t = q.front();
q.pop();
vector<int> v;
if (st[t] == 0)
v.push_back(t);
for (int u : e[t])
{
if (vis[u])
continue;
if (v.size())
v.push_back(u);
q.push(u);
vis[u] = 1;
}
if (v.size() >= 2)
res.push_back(v);
}
cout << res.size() << endl;
for (auto t : res)
{
cout << t[0] << ' ' << t.size() - 1 << ' ';
for (int k = 1; k < t.size(); k++)
cout << t[k] << " ";
cout << endl;
}
return;
}
}
}
signed main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int t = 1;
// cin >> t;
while (t--)
solve();
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 5728kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
2 1 2 2 3 2 1 4
result:
wrong answer Token parameter [name=pans] equals to "2", doesn't correspond to pattern "Yes|No"