QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#777893 | #9525. Welcome to Join the Online Meeting! | Lbl | WA | 1ms | 12092kb | C++14 | 2.0kb | 2024-11-24 10:48:30 | 2024-11-24 10:48:31 |
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[200005]={0};//
int v3[200005]={0};//标记
struct {
int from,to,next;
}a1[200005];
int head1[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){
a1[s].from=e;
a1[s].to=t;
a1[s].next=head1[e];
head1[e]=s;
s++;
// printf("%d\n",t);
v[t]=1;
v1[e]++;
if(b[t]==0){
if(v1[e]>=1&&v3[e]==0){
v3[e]=1;
s0++;
}
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){
v2[i]=1;
v[i]=1;
s=1;
s0=1;
dfs(i);
if(s==n){
l=1;
break;
}
else{
l=0;
break;
}
}
}
if(l==1){
printf("Yes\n");
printf("%d\n",s0);
for(int i=1;i<=n;i++){
if(b[i]==0){
printf("%d %d ",i,v1[i]);
for(int j=head1[i];j>0;j=a1[j].next){
printf("%d ",a1[j].to);
}
}
printf("\n");
}
/* 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");
}*/
}
if(l==0){
printf("No\n");
}
return 0;
}
/*
9 13 2
3 4
1 2
1 3
1 4
1 5
2 5
2 6
2 7
3 8
3 9
4 7
4 5
5 8
5 9
Yes
4
1
3
2
7
4
6
5
9
8
4 5 2
3 4
1 2
1 3
2 3
3 4
2 4
Yes
2
1
3
2
4
*/
详细
Test #1:
score: 100
Accepted
time: 0ms
memory: 12076kb
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: 1ms
memory: 12004kb
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: 1ms
memory: 12092kb
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]