QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#841549#9525. Welcome to Join the Online Meeting!forgive_WA 0ms16032kbC++141.5kb2025-01-03 20:13:262025-01-03 20:13:27

Judging History

This is the latest submission verdict.

  • [2025-01-03 20:13:27]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 16032kb
  • [2025-01-03 20:13:26]
  • 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 ;
		for(int t : E[x] ) {
			if( t == fa ) continue ;
			op[step].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 ;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 16032kb

input:

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

output:

Yes
2
2 1 1 
1 2 3 4 

result:

wrong answer on step #2, member 4 is not friend of 1