QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#750778#9525. Welcome to Join the Online Meeting!jotaml#WA 0ms20172kbC++141.7kb2024-11-15 15:54:562024-11-15 15:54:56

Judging History

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

  • [2024-11-15 15:54:56]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:20172kb
  • [2024-11-15 15:54:56]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long 
using namespace std;
const int N=400005;

int n,m,k,a[N],vis[N],head[N],ocp[N],ans[N];
int cnt,tot;
queue <int> q;
vector <int> vec[N];
struct qwq{
	int to,hext;
}e[N];

void add(int x,int y) {
	e[++tot].to=y;
	e[tot].hext=head[x];
	head[x]=tot;
}


void bfs(int x) {
	vis[x]=1;
	while (!q.empty()) {
		int u=q.front(); ans[++cnt]=u;
		q.pop();
		for (int i=head[u];i;i=e[i].hext) {
			int v=e[i].to;
			if (ocp[v]) continue;
			if (vis[v]) continue;
			q.push(v);
			vis[v]=1;
			vec[cnt].push_back(v);
		}
		if ((int)vec[cnt].size()==0) cnt--;
	}	
	return ;
}

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
 	cin>>n>>m>>k;
 	for (int i=1;i<=k;i++) cin>>a[i];
 	for (int i=1;i<=k;i++) ocp[a[i]]=1;
 	for (int i=1;i<=m;i++) {
 		int x,y; cin>>x>>y;
		 add(x,y); add(y,x);	
	}
	int kk=0;
	for (int i=1;i<=n;i++) {
		if (!ocp[i]) {
			kk=i; 
			q.push(i); 
			break;
		}
	} 	
	if (k==n) {
		cout<<"No"<<'\n';
		return 0;
	}
	cnt=0;
	bfs(kk); 
//	cout<<"qwq cnt="<<cnt<<endl;
	for (int i=1;i<=n;i++) {
		int u=i;
		if (!vis[i]) continue;
		if (ocp[i]) continue;
		ans[++cnt]=i;
		for (int i=head[u];i;i=e[i].hext) {
			int v=e[i].to;
			if (!vis[v]) {
				vis[v]=1; vec[cnt].push_back(v);
			}
		}
		if ((int)vec[cnt].size()==0) cnt--;
	}
	bool tf=1;
	for (int i=1;i<=n;i++) {
		if (vis[i]==0) tf=0;
	}	
	if (tf==0) {
		cout<<"No"<<'\n';
		return 0;
	}
	else {
		cout<<"Yes"<<'\n';
		cout<<cnt<<'\n';
		for (int i=1;i<=cnt;i++) {
			cout<<ans[i]<<' ';
			cout<<(int)vec[i].size()<<' ';
			for (auto j:vec[i]) cout<<j<<' '; 
			cout<<'\n';
		}
		
		
		
	}
	
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

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

output:

Yes
3
1 1 2 
1 1 3 
2 1 4 

result:

wrong answer on step #2, member 1 has invited someone before