QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#717876 | #9525. Welcome to Join the Online Meeting! | 20225954# | WA | 2ms | 7040kb | C++20 | 1.6kb | 2024-11-06 19:10:16 | 2024-11-06 19:10:16 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn=2e5+10;
int flag[maxn],busy[maxn];
queue<int> q;
vector<int> v[maxn];
vector<int> ans[maxn];
vector<int> u;
void solve(){
int n,m,k;
cin>>n>>m>>k;
memset(flag,0,sizeof(flag));
memset(busy,0,sizeof(busy));
for(int i=1;i<=k;i++){
int num;
cin>>num;
busy[num]=1;
}
for(int i=1;i<=m;i++){
int a,b;
cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
int fa=0;
if(n==k){
cout<<"No"<<'\n';
return;
}
for(int i=1;i<=n;i++){
if(!busy[i]){
fa=i;
break;
}
}
q.push(fa);
flag[fa]=1;
int cnt=1;
int now=0;
while(!q.empty()){
int num=q.front();
q.pop();
u.push_back(num);
for(auto x:v[num]){
if(!flag[x]){
cnt++;
flag[x]=1;
ans[now].push_back(x);
if(!busy[x]){
q.push(x);
}
}
}
now++;
}
if(cnt==n){
cout<<"Yes"<<'\n';
cout<<now<<'\n';
for(int i=0;i<now;i++){
cout<<u[i]<<" "<<ans[i].size()<<" ";
for(auto x:ans[i]){
cout<<x<<" ";
}
cout<<'\n';
}
}
else{
cout<<"No"<<'\n';
}
}
int main()
{
ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int t;
t=1;
while(t--){
solve();
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 2ms
memory: 7040kb
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: 5096kb
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: 5880kb
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]