QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#754740 | #9525. Welcome to Join the Online Meeting! | qcfff# | WA | 0ms | 8740kb | C++11 | 1.1kb | 2024-11-16 15:42:43 | 2024-11-16 15:42:44 |
Judging History
answer
#include<bits/stdc++.h>
//#define int long long
using namespace std;
vector<int> v[200010];
queue<int> q;
bool o[200010],vis[200010],vi[200010];
int n,m,k,a,b,r,ans=0;
signed main(){
cin>>n>>m>>k;
for(int i=1;i<=k;i++){
cin>>a;o[a]=1;
}
for(int i=1;i<=m;i++){
cin>>a>>b;
v[a].push_back(b);
v[b].push_back(a);
}
for(int i=1;i<=n;i++){
if(!o[i]){
r=i;
q.push(i);break;
}
}
vis[r]=1;
while(!q.empty()){
int x=q.front();q.pop();
if(vis[x]&&x!=r) continue;
if(o[x]) continue;
++ans;
for(int i=0;i<v[x].size();i++){
if(!vis[v[x][i]]) q.push(v[x][i]);
vis[v[x][i]]=1;
}
}
for(int i=1;i<=n;i++){
if(!vis[i]){
puts("No");
return 0;
}
}
puts("Yes");
cout<<ans<<endl;
q.push(r);vi[r]=1;
while(!q.empty()){
int x=q.front();q.pop();
if(vi[x]&&x!=r) continue;
if(o[x]) continue;
int w=0;
for(int i=0;i<v[x].size();i++){
if(!vi[v[x][i]]) ++w;
}
if(w) cout<<x<<' '<<w<<' ';
for(int i=0;i<v[x].size();i++){
if(!vi[v[x][i]]){
cout<<v[x][i]<<' ';
q.push(v[x][i]);
vi[v[x][i]]=1;
}
}
cout<<'\n';
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 8740kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
No
result:
wrong answer jury has found a solution, but participant hasn't