QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#758949 | #9525. Welcome to Join the Online Meeting! | Lbl | RE | 3ms | 24044kb | C++14 | 1.5kb | 2024-11-17 20:37:47 | 2024-11-17 20:37:47 |
Judging History
answer
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
int n,m,k;
int s,s0;
struct {
int from,to,next;
}a[200005];
int b[200005]={0};
int head[200005]={0};
int v[200005]={0};
int v1[200005]={0};
int v2[2005][2005]={0};
int v3[200005]={0};
void dfs(int e){
for(int j=head[e];j>0;j=a[j].next){
int t=a[j].to;
if(v[t]==0){
v1[e]++;
// printf("%d\n",t);
v2[e][v1[e]]=t;
v[t]=1;
dfs(t);
}
}
}
int main(){
scanf("%d %d %d",&n,&m,&k);
int c;
for(int i=1;i<=k;i++){
scanf("%d",&c);
b[c]=1;
}
int g,h;
int f=1;
for(int i=1;i<=m;i++){
scanf("%d %d",&g,&h);
if(b[i]==0){
a[f].from=g;
a[f].to=h;
a[f].next=head[g];
head[g]=f;
f++;
}
if(b[h]==0){
a[f].from=h;
a[f].to=g;
a[f].next=head[h];
head[h]=f;
f++;
}
}
int l=0;
for(int i=1;i<=n;i++)
{
if(b[i]==0){
memset(v,0,sizeof(v));
memset(v1,0,sizeof(v1));
memset(v2,0,sizeof(v2));
memset(v3,0,sizeof(v3));
v[i]=1;
s=0;
dfs(i);
s0=0;
for(int i=1;i<=n;i++){
if(v[i]==1)
{
s++;
}
if(v1[i]>=1){
s0++;
v3[s0]=i;
}
}
if(s==n){
printf("Yes\n");
printf("%d\n",s0);
for(int i=1;i<=s0;i++){
printf("%d %d ",v3[i],v1[v3[i]]);
for(int j=1;j<=v1[v3[i]];j++){
printf("%d ",v2[i][j]);
}
printf("\n");
}
l=1;
break;
}
}
}
if(l==0){
printf("No\n");
}
return 0;
}
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 24044kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 2 1 2 3 2 2 1 4
result:
ok ok
Test #2:
score: 0
Accepted
time: 0ms
memory: 23976kb
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: 0
Accepted
time: 0ms
memory: 24044kb
input:
4 6 2 3 4 1 3 1 4 2 3 2 4 1 2 3 4
output:
Yes 1 1 3 2 4 3
result:
ok ok
Test #4:
score: 0
Accepted
time: 3ms
memory: 23976kb
input:
6 6 0 1 2 2 3 3 1 4 5 5 6 6 4
output:
No
result:
ok ok
Test #5:
score: -100
Runtime Error
input:
200000 199999 2 142330 49798 49798 116486 116486 64386 64386 192793 192793 61212 61212 138489 138489 83788 83788 89573 89573 8596 8596 156548 156548 41800 41800 14478 14478 27908 27908 82806 82806 9353 9353 160166 160166 92308 92308 36265 36265 126943 126943 190578 190578 191148 191148 177381 177381...