QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#768630#9525. Welcome to Join the Online Meeting!wk6_WA 1ms5624kbC++171.1kb2024-11-21 13:04:112024-11-21 13:04:25

Judging History

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

  • [2024-11-21 13:04:25]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:5624kb
  • [2024-11-21 13:04:11]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define inf 0x3f3f3f3f3f3f3f3f
#define PII pair<int, int>
const int N = 2e6 + 10;
int n,m,k,pr[N],a[N];
int find(int x){
	if(pr[x]==x)return x;
	return pr[x]=find(pr[x]);
}
void join(int x,int y){
	int fx=find(x),fy=find(y);
	if(fx!=fy){
		pr[fx]=fy;
	}
}
void solve() {
    cin>>n>>m>>k;
	map<int,int>mp;
	for(int i=1;i<=n;i++)pr[i]=i;
	for(int i=1;i<=k;i++){
		cin>>a[i];
		mp[a[i]]=1;
	}
	vector<PII>ans;
	for(int i=1;i<=m;i++){
		int u,v;
		cin>>u>>v;
		if(find(u)!=find(v)){
			if(mp[u]==0){
				join(v,u);
			ans.push_back({u,v});
			}
			else if(mp[v]==0){
				join(u,v);
			  ans.push_back({v,u});
			}
			}
	}
	int cnt=0;
	for(int i=1;i<=n;i++){
		if(pr[i]==i)cnt++;
	}
	if(cnt!=1)cout<<"No"<<endl;
	else{
		cout<<"Yes"<<endl;
		cout<<ans.size()<<endl;
		for(int i=0;i<ans.size();i++){
			cout<<ans[i].first<<" "<<1<<" "<<ans[i].second<<endl;
		}
	}
}
signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	int _ = 1;
//	cin >> _;
	while (_--){
		solve();
	}
	return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 5624kb

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