QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#746391#9525. Welcome to Join the Online Meeting!yyc4591#WA 1ms3536kbC++201.6kb2024-11-14 14:28:502024-11-14 14:28:50

Judging History

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

  • [2024-11-14 14:28:50]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3536kb
  • [2024-11-14 14:28:50]
  • 提交

answer

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

const int N = 2e5 + 10;
vector<int> adj[N];

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<pair<int, vector<int>>> ans;

    vector<int> vis(n + 10, 0);
    for (int i = 1; i <= k; i++) {
        int t;
        cin >> t;
        vis[t] = 1;
    }

    for (int i = 1; i <= m; i++) {
        int p, q;
        cin >> p >> q;
        adj[p].push_back(q);
        adj[q].push_back(p);
    }

    queue<int> Q;
    int cnt = 0;
    vector<int> vis2(n + 10, 0);
    for (int i = 1; i <= n; i++) {
        if(!vis[i]) {
            Q.push(i);
            vis2[i] = 1;
            ++cnt;
            break;
        }
    }
    while(Q.size()) {
        int u = Q.front();
        Q.pop();
        if(vis[u] == 1) continue;
        vector<int> res;
        for (auto v : adj[u]) {
            if(++vis2[v] == 1) {
                Q.push(v);
                cnt++;
                res.push_back(v);
            }
        }
        if(res.size() == 0) continue;
        ans.push_back({u, res});
    }

    if(cnt == n) {
        cout << "Yes\n";
        for (auto [u, res] : ans) {
            cout << u << " ";
            cout << res.size() << " ";
            for (auto it : res) {
                cout << it << " ";
            }
            cout << "\n";
        }
    } else {
        cout << "No\n";
    }
}
signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int T = 1;
    // cin >> T;
    while (T--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3536kb

input:

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

output:

Yes
1 2 2 3 
2 1 4 

result:

wrong answer on step #1, member 2 has been invited