QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#706690#9525. Welcome to Join the Online Meeting!leafmaple#WA 2ms7748kbC++201.1kb2024-11-03 12:59:312024-11-03 12:59:33

Judging History

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

  • [2024-11-03 12:59:33]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:7748kb
  • [2024-11-03 12:59:31]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define ll long long  
const int N = 1e6+5;
vector<int>g[N];
int a[N], vis[N], del[N];

int n, m, k;
vector<pair<int,vector<int>>>ans;

int cnt = 0;
void dfs(int u, int v){
	vector<int>cur;
	for(auto v: g[u])if(!vis[v]){
		vis[v] = 1;
		cnt++;
		cur.push_back(v);
		if(!del[v]){
			dfs(v, u);
		}
	}
	// cout << u << ' ';
	// for(auto x: cur) cout << x << ' ';
	// cout<<endl;
	if(!cur.empty())ans.push_back({u, cur});
}

signed main (){
	std::ios::sync_with_stdio(false);  
	cin.tie(NULL); 
	cout.tie(NULL);
	
	cin >> n >> m >> k;
	for(int i=1; i<=k; i++){
		cin >> a[i];
		del[a[i]] = 1;
	}
	for(int i=1; i<=m; i++){
		int u, v; cin >> u >> v;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	for(int i=1; i<=n; i++)if(!del[i]){
		cnt ++; vis[i] = 1;
		dfs(i, 0);
		break;
	}
	reverse(ans.begin(), ans.end());
	if(cnt != n) cout << "No" << endl;
	else {
		cout<<"Yes"<<endl;
		for(auto [id, vec]: ans){
			cout << id << ' ';
			cout << vec.size() << ' ';
			for(auto x: vec) cout << x << ' ';
			cout<<endl;
		}
	}
	
	
} 

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 2ms
memory: 7748kb

input:

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

output:

Yes
1 1 2 
2 2 3 4 

result:

wrong answer on step #1, member 2 has been invited