QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#754597#9525. Welcome to Join the Online Meeting!qcfff#WA 2ms8360kbC++111.1kb2024-11-16 15:23:022024-11-16 15:23:02

Judging History

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

  • [2024-11-16 15:23:02]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8360kb
  • [2024-11-16 15:23:02]
  • 提交

answer

#include<bits/stdc++.h>
//#define int long long
using namespace std;
vector<int> v[200010];
queue<int> q;
bool o[200010],vis[200010],vi[200010];
int n,m,k,a,b,r,ans=0;
signed main(){
	cin>>n>>m>>k;
	for(int i=1;i<=k;i++){
		cin>>a;o[a]=1;
	}
	for(int i=1;i<=m;i++){
		cin>>a>>b;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	for(int i=1;i<=n;i++){
		if(!o[i]){
			r=i;
			q.push(i);break;
		}
	}
	while(!q.empty()){
		int x=q.front();q.pop();
		if(vis[x]) continue;
		vis[x]=1;
		if(o[x]) continue;
		++ans;
		for(int i=0;i<v[x].size();i++){
			q.push(v[x][i]);
		}
	}
	for(int i=1;i<=n;i++){
		if(!vis[i]){
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	cout<<ans<<endl;
	q.push(r);
	while(!q.empty()){
		int x=q.front();q.pop();
		vi[x]=1;
		if(o[x]) continue;
		int w=0;
		cout<<x<<' ';
		for(int i=0;i<v[x].size();i++){
			if(!vi[v[x][i]]) ++w;
		}
		cout<<w<<' ';
		for(int i=0;i<v[x].size();i++){
			if(!vi[v[x][i]]){
				cout<<v[x][i]<<' ';
				q.push(v[x][i]);
				vi[v[x][i]]=1;
			}
		}
		cout<<'\n';
	}
	return 0;
}

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 8300kb

input:

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

output:

Yes
2
1 2 2 3 
2 1 4 

result:

ok ok

Test #2:

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

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: 2ms
memory: 8304kb

input:

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

output:

Yes
2
1 3 3 4 2 
2 0 

result:

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