QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#780695#9525. Welcome to Join the Online Meeting!chenjiaqiyWA 2ms7752kbC++201.7kb2024-11-25 12:30:242024-11-25 12:30:27

Judging History

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

  • [2024-11-25 12:30:27]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7752kb
  • [2024-11-25 12:30:24]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define endl '\n'
#define all(a) a.begin(), a.end()
#define pb push_back
#define x first
#define y second
#define debug(_x) cout << #_x << '=' << _x << endl
typedef pair<int, int> PII;
using i64 = long long;
const int mod = 1e9 + 7;
const int N = 5e5 + 10;

int vis[N], ok[N];
vector<int> p[N], ans[N];

void solve()
{
    int n, m, k;
    cin >> n >> m >> k;
    for (int i = 1; i <= k; i++)
    {
        int x;
        cin >> x;
        vis[x] = 1;
    }
    while (m--)
    {
        int u, v;
        cin >> u >> v;
        p[u].pb(v), p[v].pb(u);
    }
    for (int i = 1; i <= n; i++)
    {
        if (vis[i])
            continue;
        ok[i] = 1;
        for (auto j : p[i])
        {
            if (!ok[j])
            {
                ans[i].pb(j);
                ok[j] = 1;
            }
        }
    }
    for (int i = 1; i <= n; i++)
    {
        if (vis[i] && !ok[i])
        {
            cout << "No\n";
            return;
        }
    }
    int cnt = 0;
    for (int i = 1; i <= n; i++)
    {
        if (!ans[i].empty())
            cnt++;
    }
    cout << "Yes\n";
    cout << cnt << endl;
    for (int i = 1; i <= n; i++)
    {
        if (!ans[i].empty())
        {
            cout << i << " " << ans[i].size() << " ";
            for (auto j : ans[i])
                cout << j << " ";
            cout << endl;
        }
    }
}

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int _ = 1;
    // cin >> _;

    while (_--)
        solve();

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 2ms
memory: 7748kb

input:

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

output:

Yes
2
1 2 2 3 
2 1 4 

result:

ok ok

Test #2:

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

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: 0
Accepted
time: 0ms
memory: 7752kb

input:

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

output:

Yes
1
1 3 3 4 2 

result:

ok ok

Test #4:

score: -100
Wrong Answer
time: 1ms
memory: 5708kb

input:

6 6 0

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

output:

Yes
2
1 2 2 3 
4 2 5 6 

result:

wrong answer on step #2, member 4 is not invited before inviting others