QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706493#9525. Welcome to Join the Online Meeting!2366503423WA 0ms3536kbC++141.5kb2024-11-03 11:43:302024-11-03 11:43:30

Judging History

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

  • [2024-11-03 11:43:30]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3536kb
  • [2024-11-03 11:43:30]
  • 提交

answer

#include <bits/stdc++.h> 
using namespace std;
map <int,int> cha;
int find(int x)
{
	if(cha[x]==x) return x;
	return cha[x]=find(cha[x]);
}
int main()
{
	int n,m,k;cin>>n>>m>>k;
	map <int,bool> book;
	vector <pair<int,int>> a,b;
	for(int i=1;i<=n;i++) cha[i]=i;
	while(k--)
	{
		int x;cin>>x;
		book[x]=1;
	}
	vector <int> cnt(n+1,0);
	while(m--)
	{
		int x,y;cin>>x>>y;
		a.push_back({x,y});
		if(book[x]!=1&&book[y]!=1) {cha[find(x)]=find(y);cnt[x]++;cnt[y]++;}
		else{b.push_back({x,y});}
	}
	for(int i=0;i<b.size();i++)
	{
		int x=b[i].first,y=b[i].second;
		if(book[x]==1&&book[y]!=1) cha[x]=find(y);
		if(book[y]==1&&book[x]!=1) cha[y]=find(x);
	}
	int zhu=cha.begin()->second;
	bool f=1;
	for(auto &i:cha)
	{
		if(zhu!=i.second){f=0;break;}
	}
	if(f==0){cout<<"No";return 0;}
	sort(cnt.begin(),cnt.end());
	map <int,set<int>> ans;
	map <int,bool> la;
	zhu=cnt[cnt.size()-1];
	cout<<zhu<<'\n';
	la[zhu]=1;
	for(int i=0;i<a.size();i++)
	{
		int x=a[i].first,y=a[i].second;
		if(book[x]!=1)
		{
			if(la[y]!=1)
			{
				ans[x].insert(y);
				la[y]=1;
			}
		}
		if(book[y]!=1)
		{
			if(la[x]!=1)
			{
				ans[y].insert(x);
				la[x]=1;
			}
		}
	}
	cout<<"Yes"<<'\n';
	cout<<ans.size()<<'\n';
	queue <int> dui;
	dui.push(zhu);
	while(dui.size()>0)
	{
		int y=dui.front();
		dui.pop();
		cout<<y<<' '<<ans[y].size();
		for(auto &j:ans.find(y)->second)
		{
			cout<<' '<<j;
			if(ans.find(j)!=ans.end()) dui.push(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: 3536kb

input:

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

output:

1
Yes
2
1 2 2 3
2 1 4

result:

wrong answer Token parameter [name=pans] equals to "1", doesn't correspond to pattern "Yes|No"