QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#884408#9525. Welcome to Join the Online Meeting!1903331632WA 1ms5728kbC++232.4kb2025-02-06 04:32:292025-02-06 04:32:30

Judging History

This is the latest submission verdict.

  • [2025-02-06 04:32:30]
  • Judged
  • Verdict: WA
  • Time: 1ms
  • Memory: 5728kb
  • [2025-02-06 04:32:29]
  • Submitted

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"