QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#725159#9525. Welcome to Join the Online Meeting!Lisens#WA 0ms3828kbC++201.9kb2024-11-08 16:29:572024-11-08 16:29:57

Judging History

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

  • [2024-11-08 16:29:57]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3828kb
  • [2024-11-08 16:29:57]
  • 提交

answer

#include<bits/stdc++.h>
#define endl '\n'
#define all(x) x.begin(),x.end()
#define ios ios::sync_with_stdio(false);cin.tie(0),cout.tie(0)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using pii = pair<int, int>;
using pll = pair<long long, long long>;

void solve() {
    ll n, m , k;
    cin >> n  >> m >> k;
    vector<vector<ll>> G(n);
    vector<ll> b(k);
    for(auto&& i : b) {
        cin >> i;
        i--;
    }
    set<ll> setb(b.begin(), b.end());
    while(m--) {
        ll u, v;
        cin >> u >> v;
        u--, v--;
        G[u].push_back(v);
        G[v].push_back(u);
    }
    ll start = -1;
    for(int i = 0 ; i < n ; i++) {
        if(!setb.count(i)) {
            start = i;
            break;
        }
    }
    if(start == -1) {
        cout << "NO" << endl;
        return;
    }
    string ans;
    queue<ll> q;
    set<ll> vis;
    q.push(start);
    vis.insert(start);
    ll numline = 0;
    while(!q.empty()) {
        ll t = q.front();
        ans += to_string(t + 1) + ' ';
        q.pop();
        ll cnt = 0;
        vector<ll> rec;
        for(auto v : G[t]) {
            if(!vis.count(v)) {
                cnt++;
                rec.push_back(v);
                if(!setb.count(v)) {
                    q.push(v);
                }
                vis.insert(v);
            }
        }
        if(cnt > 0) {
            numline++;
            ans += to_string(cnt) + ' ';
            for(auto i : rec) {
                ans += to_string(i + 1) + ' ';
            }
        }
        ans += endl;
    }
    if(vis.size() != n) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
        cout << numline << endl;
        cout << ans;
    }
}

signed main() {
    ios;
    int _ = 1;
    //cout << fixed << setprecision(2);
    //cin >> _;
    while(_--) solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3828kb

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: 3564kb

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: 3568kb

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 
2 

result:

wrong output format Extra information in the output file