QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#841547#9525. Welcome to Join the Online Meeting!forgive_WA 85ms38172kbC++141.5kb2025-01-03 20:11:202025-01-03 20:11:20

Judging History

This is the latest submission verdict.

  • [2025-01-03 20:11:20]
  • Judged
  • Verdict: WA
  • Time: 85ms
  • Memory: 38172kb
  • [2025-01-03 20:11:20]
  • 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(x)] = Find(y) ;
					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(1,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: 3ms
memory: 16280kb

input:

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

output:

Yes
2
1 1 2 
2 2 4 3 

result:

ok ok

Test #2:

score: 0
Accepted
time: 3ms
memory: 15968kb

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

input:

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

output:

Yes
1
1 3 3 4 2 

result:

ok ok

Test #4:

score: 0
Accepted
time: 3ms
memory: 15988kb

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
Wrong Answer
time: 85ms
memory: 38172kb

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:

Yes
199998
1 1 95113 
95113 1 27292 
27292 1 93394 
93394 1 30051 
30051 1 174891 
174891 1 165580 
165580 1 94294 
94294 1 123410 
123410 1 55130 
55130 1 154872 
154872 1 166138 
166138 1 30681 
30681 1 51031 
51031 1 89161 
89161 1 187764 
187764 1 14291 
14291 1 66035 
66035 1 83781 
83781 1 132...

result:

wrong answer on step #73236, member 178679 is not friend of 116486