QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#724814 | #9525. Welcome to Join the Online Meeting! | xydCatGirl# | WA | 2ms | 5628kb | C++20 | 1.3kb | 2024-11-08 15:10:03 | 2024-11-08 15:10:06 |
Judging History
answer
#include<bits/stdc++.h>
#define ll long long
#define N 500005
#define endl "\n"
#define fi first
#define se second
using namespace std;
const ll mod=1e9+7;
const ll inf=1e18;
const double eps=1e-6;
ll n,m,k;
ll vis[N],fl[N],cnt[N];
vector<ll>v[N];
vector<ll>ans[N];
void dfs(ll x){
fl[x]=1;
if(vis[x])return ;
for(auto y:v[x]){
if(fl[y])continue;
ans[x].push_back(y);
dfs(y);
}
}
void dfs2(ll x){
fl[x]=1;
if(vis[x])return ;
if(ans[x].size()>0){
cout<<x<<" "<<ans[x].size()<<" ";
for(auto y:ans[x])cout<<y<<" ";
cout<<endl;
}
for(auto y:v[x]){
if(fl[y])continue;
dfs2(y);
}
}
int main(){
//freopen(".in","r",stdin);
//freopen(".out","w",stdout);
cin>>n>>m>>k;
for(int i=1;i<=k;i++){
ll x;
cin>>x;
vis[x]=1;
}
for(int i=1;i<=m;i++){
ll x,y;
cin>>x>>y;
v[x].push_back(y);
v[y].push_back(x);
}
for(int i=1;i<=n;i++){
if(!vis[i]&&!fl[i]){
dfs(i);
break;
}
}
for(int i=1;i<=n;i++){
if(!fl[i]){
cout<<"No\n";
return 0;
}
fl[i]=0;
}
cout<<"Yes\n";
for(int i=1;i<=n;i++)if(!vis[i]&&!fl[i])dfs2(i);
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 2ms
memory: 5628kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 1 1 2 2 2 3 4
result:
wrong answer on step #1, member 2 has been invited