QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#711371 | #9525. Welcome to Join the Online Meeting! | xyz123# | WA | 11ms | 30504kb | C++23 | 2.3kb | 2024-11-05 10:02:31 | 2024-11-05 10:02:31 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const long long mod=1e9+7;
long long T,a,b,c,d[1000001],v[1000001],o,h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001],cn1,cn2,st1[1000001],st2[1000001];
char s[1000001],bg,ls;
struct p{long long q,w;}l[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
char t[4];
vector<int> qu[1000001],ve[1000001];
queue<int> quu;
int main()
{
// freopen("1.in","r",stdin);
srand((unsigned)(time(0)^(*new int)));
fac[0]=1;for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
inv[1000000]=pow_(fac[1000000],mod-2);for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
T=1;
t[0]='N';
t[1]='E';
t[2]='S';
t[3]='W';
// scanf("%lld",&T);
for(int ii=1;ii<=T;ii++)
{
scanf("%lld%lld%lld",&a,&b,&c);
for(int i=1;i<=c;i++) d[i]=read(),v[d[i]]=1;
for(int i=1;i<=b;i++)
{
q=read(),w=read();
qu[q].push_back(w);
qu[w].push_back(q);
}
int rt=0;
for(int i=1;i<=a;i++)
{
if(!v[i])
{
rt=i;
break;
}
}
if(!rt)
{
printf("No");return 0;
}
h[rt]=1;
quu.push(rt);
while(!quu.empty())
{
int r=quu.front();quu.pop();
for(int i=0;i<qu[r].size();i++)
{
if(!h[qu[r][i]])
{
h[qu[r][i]]=1;
ve[r].push_back(qu[r][i]);
if(!v[qu[r][i]]) quu.push(qu[r][i]);
}
}
if(ve[r].size()>0) st[++cn]=r;
}
for(int i=1;i<=a;i++)
{
if(!h[i])
{
printf("No");return 0;
}
}
printf("Yes\n");
printf("%lld\n",cn);
for(int i=1;i<=cn;i++)
{
printf("%lld ",st[i]);
for(int j=0;j<ve[st[i]].size();j++) printf("%d ",ve[st[i]][j]);
printf("\n");
}
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 11ms
memory: 30504kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 2 1 2 3 2 4
result:
wrong answer on step #2, member 4 invited others when being banned