QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#750962#9525. Welcome to Join the Online Meeting!surenjamtsWA 1ms3708kbC++201.1kb2024-11-15 16:32:032024-11-15 16:32:03

Judging History

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

  • [2024-11-15 16:32:03]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3708kb
  • [2024-11-15 16:32:03]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define F first
#define S second
bool yes = 1;
vector < int > vc[200045], ans[200045];
bool vis[200045], gg[200045];
int lla = 0;
void dfs( int node ){
	vis[node] = 1;
	lla ++;
	if( gg[node] ){
		return;
	}
	for(int i : vc[node] ){
		if( vis[i] == 0 ){
				ans[node].pb( i );
			dfs( i );
		}
		
	}
}
signed main(){
	int n, m, k;
	int a, b, e;
	cin >> n >> m >> k;
	for(int i = 1; i <= k; i ++ ){
		cin >> e;
		gg[e] = 1;
	}
	for(int i = 1; i <= m; i ++ ){
		cin >> a >> b;
		vc[a].pb( b );
		vc[b].pb( a );
	}
	
	for(int i = 1; i <= n; i ++ ){
		if( vis[i] == 0 && gg[i] == 0 ){
			dfs( i );
		}	
	}
	if( lla < n ){
		cout << "No";
		return 0;
	}
	cout << "Yes\n";
	int cnt = 0;
	for(int i = 1; i <= n; i ++ ){
		if( ans[i].size() )
			cnt ++;
	}
	cout << cnt << "\n";
	for(int i = 1; i <= n; i ++ ){
		if( ans[i].size() > 0 ){
			cout << i << " " << ans[i].size() << " ";
		}
		for(int j : ans[i] )
			cout << j << " ";
		cout << "\n";
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

Yes
2
1 1 2 
2 2 3 4 



result:

ok ok

Test #2:

score: 0
Accepted
time: 1ms
memory: 3708kb

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: 1ms
memory: 3556kb

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: -100
Wrong Answer
time: 1ms
memory: 3688kb

input:

6 6 0

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

output:

Yes
4
1 1 2 
2 1 3 

4 1 5 
5 1 6 


result:

wrong answer on step #3, member 4 is not invited before inviting others