QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#727285#9525. Welcome to Join the Online Meeting!pugong#WA 0ms3552kbC++201.9kb2024-11-09 12:30:482024-11-09 12:30:51

Judging History

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

  • [2024-11-09 12:30:51]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3552kb
  • [2024-11-09 12:30:48]
  • 提交

answer

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


void solve() {
    int n, m, k;cin >> n >> m >> k;
    vector<int>mp(n + 1, 0), ok(n + 1, 0);
    for (int i = 1;i <= k;i++) {
        int x;cin >> x;
        mp[x] = 1;
        ok[x] = 1;
    }
    int ans = 1;
    vector<vector<int>>g(n + 1);
    for (int i = 1;i <= m;i++) {
        int u, v;cin >> u >> v;
        g[u].push_back(v);
        g[v].push_back(u);
        if (mp[u] && !mp[v]) ok[u] = 0;
        if (mp[v] && !mp[u]) ok[v] = 0;
    }
    int p = 1;
    for (int i = 1;i <= n;i++) {
        if (ok[i]) ans = 0;
        if (!mp[i]) p = i;
    }
    //cout << p << "--\n";
    vector<int>st(n + 1, 0);
    vector<int>id(n + 1, -1);
    int cnt = 1;
    auto dfs = [&](auto self, int u)->void {
        id[cnt++] = u;
        for (auto i : g[u]) {
            if (st[i]) continue;
            st[i] = 1;
            if (!mp[i]) {
                self(self, i);
            }
        }
        };
    st[p] = 1;
    dfs(dfs, p);
    for (int i = 1;i <= n;i++) {
        if (!st[i]) {
            ans = 0;
            //cout << i << "+\n";
        }
    }
    vector<int>use(n + 1, 0);
    if (!ans) {
        cout << "No\n";
    }
    else {
        cout << "Yes\n";
        for (int i = 0;i <= cnt;i++) {
            //cout << id[i] << "+\n";
            if (id[i] == -1 || use[id[i]]) continue;
            int op = 0;
            for (auto j : g[id[i]]) {
                if (!use[j]) op++;
            }
            cout << id[i] << " " << op << " ";
            for (auto j : g[id[i]]) {
                if (!use[j]) cout << j << " ";
                use[j] = 1;
            }
            cout << "\n";
        }
    }
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int T = 1;
    //cin >> T;
    while (T--) {
        solve();
    }
    return 0;
}

详细

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3552kb

input:

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

output:

Yes
2 3 1 3 4 

result:

wrong answer on step #1, member 3 invited others when being banned