QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#754717 | #9525. Welcome to Join the Online Meeting! | qcfff# | WA | 2ms | 8692kb | C++11 | 1.1kb | 2024-11-16 15:38:11 | 2024-11-16 15:38:11 |
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(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(o[x]) continue;
int w=0;
cout<<x<<' ';
for(int i=0;i<v[x].size();i++){
if(!vi[v[x][i]]) ++w;
}
cout<<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;
}
详细
Test #1:
score: 100
Accepted
time: 2ms
memory: 8692kb
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: 8244kb
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: 2ms
memory: 8248kb
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]