QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#841551#9525. Welcome to Join the Online Meeting!JZYZ#WA 3ms16100kbC++141.6kb2025-01-03 20:15:152025-01-03 20:15:15

Judging History

This is the latest submission verdict.

  • [2025-01-03 20:15:15]
  • Judged
  • Verdict: WA
  • Time: 3ms
  • Memory: 16100kb
  • [2025-01-03 20:15:15]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std ;

typedef long long LL ;
const int N = 2e5+10 , M = 5e5+10 ;

int n , m , K , a[N] ;
int bin[N] ;
int Find( int x ) { return x==bin[x]?x:bin[x]=Find(bin[x]) ; }
int du[N] ;
bool is[N] ;
vector<int> E[N] ;
int yuan[N] ;
vector<int> op[N] ;
int step ;
void dfs( int x , int fa )
{
	if( x == 1 || E[x].size()>1 ) { // 非叶子 
		yuan[++step] = x ;
		int th = step ;
		for(int t : E[x] ) {
			if( t == fa ) continue ;
			op[th].push_back(t) ;
			dfs(t,x) ;
		}
	}
}
  
int main()
{
	scanf("%d%d%d" , &n , &m , &K ) ;
	for(int i = 1 ; i <= n ; i ++ ) bin[i] = i ;
	for(int i = 1 ; i <= K ; i ++ ) {
		scanf("%d" , &a[i] ) ;
		is[a[i]] = 1 ;
	}
	int x , y ; 
	for(int i = 1 ; i <= m ; i ++ ) {
		scanf("%d%d" , &x , &y ) ;
		if( Find(x)!=Find(y) ) {
			if( !is[x]&&!is[y] ) bin[Find(x)] = Find(y) , E[x].push_back(y) , E[y].push_back(x) ;
			else if( is[x] && is[y] ) continue ;
			else if( is[x] ) {
				if( du[x]==0 ) {
					bin[Find(x)] = Find(y) ;
					du[x] ++ , E[x].push_back(y) ; E[y].push_back(x) ;
				}
			} 
			else {
				if( du[y]==0 ) {
					bin[Find(y)] = Find(x) ;
					du[y] ++ ; E[x].push_back(y) ; E[y].push_back(x) ;
				}
			}
		}
	}
	int rt = Find(1) ;
	for(int i = 2 ; i <= n ; i ++ ) {
		if( rt!=Find(i) ) {
			printf("No\n") ;
			return 0 ;
		}
	}
	dfs(rt,0) ;
	printf("Yes\n%d\n" , step ) ;
	for(int i = 1 ; i <= step ; i ++ ) {
		printf("%d %d " , yuan[i] , op[i].size() ) ;
		for(int id : op[i] ) printf("%d " , id ) ;
		printf("\n") ;
	}
 	return 0 ;
}

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 16100kb

input:

4 5 2
3 4
1 2
1 3
2 3
3 4
2 4

output:

Yes
2
2 2 1 4 
1 1 3 

result:

ok ok

Test #2:

score: 0
Accepted
time: 0ms
memory: 15160kb

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: 3ms
memory: 14856kb

input:

4 6 2
3 4
1 3
1 4
2 3
2 4
1 2
3 4

output:

Yes
0

result:

wrong answer Integer parameter [name=t] equals to 0, violates the range [1, 4]