QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#709949#9525. Welcome to Join the Online Meeting!0x3fffffffWA 0ms3532kbC++232.0kb2024-11-04 17:37:082024-11-04 17:37:14

Judging History

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

  • [2024-11-04 17:37:14]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3532kb
  • [2024-11-04 17:37:08]
  • 提交

answer

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


void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int>a(n + 1);
    vector<vector<int>>e(n + 1);
    for (int i = 1;i <= k;i++) {
        int x;cin >> x;
        a[x] = 1;
    }
    vector<int>vis(n + 1);
    vector<vector<int>>mp(n + 1);
    int cnt = 0;
    for (int i = 1;i <= m;i++) {
        int a, b;cin >> a >> b;
        e[a].push_back(b);
        e[b].push_back(a);
    }

    vector<int>sf;
    auto dfs = [&](auto ff, int u, int fa)->void {
        vis[u] = 1;
        if (a[u])return;
        sf.push_back(u);
        for (int v : e[u]) {
            if (vis[v])continue;
            mp[u].push_back(v);
        }
        for (int v : e[u]) {
            if (vis[v])continue;
            ff(ff, v, u);
        }
    };
    for (int i = 1;i <= n;i++) {
        if (!a[i]) {

            dfs(dfs, i, 0);
            break;
        }
    }
    // if (sf.size() != n) {
    //     cout << "No\n";return;
    // }
    for (int i = 1;i <= n;i++) {
        if (!vis[i]) {
            cout << "No\n";return;
        }
    }
    fill(vis.begin(), vis.end(), 0);
    reverse(sf.begin(), sf.end());
    vector<int>ans;
    while (sf.size()) {
        if (mp[sf.back()].size()) {
            ans.clear();
            for (auto x : mp[sf.back()]) {
                if (!vis[x]) {
                    vis[x] = 1;
                    ans.push_back(x);
                }
            }
            if (ans.size()) {
                cout << sf.back() << " " << ans.size() << " ";
                for (auto x : ans) {
                    cout << x << " ";
                }
                cout << "\n";
            }
        }
        sf.pop_back();
    }

}

signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int T = 1;
#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif
    // 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: 0ms
memory: 3532kb

input:

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

output:

1 2 2 3 
2 1 4 

result:

wrong answer Token parameter [name=pans] equals to "1", doesn't correspond to pattern "Yes|No"