QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#909299#9525. Welcome to Join the Online Meeting!wxhtzdy#WA 0ms3712kbC++201.3kb2025-02-21 17:43:582025-02-21 17:44:03

Judging History

This is the latest submission verdict.

  • [2025-02-21 17:44:03]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3712kb
  • [2025-02-21 17:43:58]
  • Submitted

answer

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m, k;
  cin >> n >> m >> k;
  vector<bool> busy(n + 1, false);
  for(int i = 0; i < k; i++) {
    int x;
    cin >> x;
    busy[x] = true;
  }
  vector<int> g[n + 1];
  for(int i = 0; i < m; i++) {
    int u, v;
    cin >> u >> v;
    g[u].push_back(v);
    g[v].push_back(u);
  }
  vector<pair<int, vector<int>>> ans;
  queue<int> q;
  vector<bool> mark(n + 1, false);
  for(int i = 1; i <= n; i++) {
    if(!busy[i]) {
      q.push(i);
      mark[i] = true;
      break;
    }
  }
  if(q.empty()) {
    cout << "No";
    return 0;
  }
  vector<bool> in(n + 1, false);
  while(!q.empty()) {
    int u = q.front();
    in[u] = true;
    q.pop();
    if(busy[u]) continue;
    vector<int> add;
    for(int v : g[u]) {
      if(mark[v]) continue;
      mark[v] = true;
      q.push(v);
      add.push_back(v);
    }
    ans.push_back({u, add});
  }
  for(int i = 1; i <= n; i++) {
    if(!in[i]) {
      cout << "No";
      return 0;
    }
  }
  cout << "Yes\n";
  cout << ans.size() << "\n";
  for(auto gas : ans) {
    cout << gas.first << " " << gas.second.size() << " ";
    for(int i : gas.second) cout << i << " ";
    cout << "\n";
  }
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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

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

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]