QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#743049#9525. Welcome to Join the Online Meeting!abovecloudWA 2ms8212kbC++141.6kb2024-11-13 18:04:452024-11-13 18:04:47

Judging History

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

  • [2024-11-13 18:04:47]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:8212kb
  • [2024-11-13 18:04:45]
  • 提交

answer

/*Time:2024-11-13 17:24:48*/

#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define second se
#define first fi
#define vi vector<int>
#define vvi vector<vi>
#define all(v) v.begin(),v.end()
const int MOD = (int) 1e9 + 7;
const int INF = INT_MAX;
const int MAXN = 1e5+5;

vi e[MAXN];
vi ans[MAXN];
void solve() {
	int n,m,k;
	
	cin >> n >> m >> k;
	vi free(n+1,1);
	vi vis(n+1,0);
	for(int i = 0;i<k;i++){
		int t;
		cin >> t;
		free[t] = 0;
	}
	for(int i = 0;i<m;i++){
		int u,v;
		cin >> u >> v;
		if(free[u])e[u].push_back(v);
		if(free[v])e[v].push_back(u);
	}
	int st = 0,tot = 1;
	queue<int> q;
	for(int i = 1;i<=n;i++){
		if(free[i]){
			st=i;
			break;
		}
	}
	if(st==0){
		cout << "NO" << endl;
		return;
	}
	int now = 0;
	q.push(st);
	vis[st]=1;
	while(!q.empty()){
		int u = q.front();q.pop();
		// cout << u << endl;
		ans[now].push_back(u);
		for(int v:e[u]){
			if(vis[v]==0){
				vis[v]=1;
				q.push(v);
				ans[now].push_back(v);
				tot++;
			}
		}
		now++;
	}
	if(tot!=n){
		cout << "NO" << endl;
		return;
	}
	int tt = now;
	for(int i=0;i<now;i++){
		if(ans[i].size()==1)tt--;
	}
	cout << "YES\n"<<tt<<endl;
	for(int i =0;i<now;i++){
		if(ans[i].size()==1)continue;
		cout << ans[i][0] << " " << ans[i].size() - 1  << " ";
		for(int j=1;j<ans[i].size();j++)cout << ans[i][j] << " ";
		cout << endl;
	}


}

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(12);
    int T = 1;
    // cin >> T;
    while (T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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:

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