QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#769883#9525. Welcome to Join the Online Meeting!LblRE 5ms24644kbC++141.5kb2024-11-21 19:45:302024-11-21 19:45:30

Judging History

你现在查看的是最新测评结果

  • [2024-11-21 19:45:30]
  • 评测
  • 测评结果:RE
  • 用时:5ms
  • 内存:24644kb
  • [2024-11-21 19:45:30]
  • 提交

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 j=1;j<=n;j++){
				if(v[j]==1)
				{
				s++;
				}
				if(v1[j]>=1){
					s0++;
					v3[s0]=j;
				}
				}
				if(s==n){
					l=1;
					break;
				}
			}
		}
		if(l==1){
			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");
					}
		}
		if(l==0){
			printf("No\n");
		}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 5ms
memory: 24040kb

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: 23504kb

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: 24644kb

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: 4ms
memory: 23896kb

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...

output:


result: