QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#790721#9525. Welcome to Join the Online Meeting!YehhhhWA 1ms3812kbC++201.6kb2024-11-28 15:01:212024-11-28 15:01:24

Judging History

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

  • [2024-11-28 15:01:24]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3812kb
  • [2024-11-28 15:01:21]
  • 提交

answer

#include <bits/stdc++.h>

using namespace std;

struct node {
    int fa;
    vector<int> num;
};

vector<node> ans;

void dfs(int now, vector<vector<int>> f, vector<int> nofree, vector<int>& inn, int& person) {
    vector<int> tmp;
    for (auto x : f[now]) {
        if (inn[x] == 0) {
            inn[x] = 1;
            person++;
            tmp.push_back(x);
            if (nofree[x] == 0) {
                dfs(x, f, nofree, inn, person);
            }
        }
    }
    ans.push_back({now, tmp});
}

void solve() {
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> nofree(n + 1);
    for (int i = 0; i < k; i++) {
        int x;
        cin >> x;
        nofree[x] = 1;
    }
    vector<vector<int>> f(n + 1);
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y;
        f[x].push_back(y);
        f[y].push_back(x);
    }
    vector<int> inn(n + 1);
    int person = 1;
    for (int i = 1; i <= n; i++) {
        if (nofree[i] == 0) {
            inn[i] = 1;
            dfs(i, f, nofree, inn, person);
            break;
        }
    }
    if (person != n) {
        cout << "No\n";
        return;
    }
    cout << "Yes\n";
    cout << ans.size() << "\n";
    for (int i = ans.size() - 1; i >= 0; i--) {
        cout << ans[i].fa << " " << ans[i].num.size();
        for (auto x : ans[i].num) {
            cout << " " << x;
        }
        cout << "\n";
    }
}

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

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3812kb

input:

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

output:

Yes
2
1 1 2
2 2 3 4

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

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

output:

No

result:

ok ok

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3532kb

input:

4 6 2
3 4
1 3
1 4
2 3
2 4
1 2
3 4

output:

Yes
2
1 3 3 4 2
2 0

result:

wrong answer Integer parameter [name=y_j] equals to 0, violates the range [1, 4]