QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#725003#9525. Welcome to Join the Online Meeting!bluejellyfishWA 1ms3792kbC++231.3kb2024-11-08 15:51:462024-11-08 15:51:54

Judging History

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

  • [2024-11-08 15:51:54]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3792kb
  • [2024-11-08 15:51:46]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define int long long
#define x first
#define y second
void miss() {
	int n,m,k;
	cin >> n >> m >> k;
	vector<vector<int>>mp(n + 1);
	vector<bool>ai(n + 1);
	for(int i = 1; i <= k; i++) {
		int a;
		cin >> a;
		ai[a] = 1;
	}
	for(int i = 1; i <= m; i++) {
		int a,b;
		cin >> a >> b;
		mp[a].push_back(b);
		mp[b].push_back(a);
	}
	int sum;
	for(int i = 1; i <= n; i++) {
		if(!ai[i]) {
			sum = i;
			break;
		}
	}
	queue<int>q;
	q.push(sum);
	vector<bool>fg(n + 1);
	vector<vector<int>>ans(n + 1);
	fg[sum] = 1;
	int zlm = 1;
	while(q.size()) {
		int x = q.front();
		q.pop();
		for(auto v : mp[x]) {
			if(!fg[v]) {
				zlm++;
				fg[v] = 1;
				ans[x].push_back(v);
				if(!ai[v]) q.push(v);
			}
		}
	}
	if(zlm != n) cout << "No\n";
	else {
		int qqq = 0;
		for(int i = 1; i <= n; i++) {
			if(ans[i].size()) qqq++;
		}		
		cout << "Yes\n";
		cout << qqq << endl;
		q.push(sum);
		while(q.size()) {
			cout << q.front() << " ";
			cout << ans[q.front()].size() << " ";
			for(auto v : ans[q.front()]) {
				cout << v << " ";
				if(!ai[v]) q.push(v);
			}
			cout << endl;
			q.pop();
		}
	} 
}
signed main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int T = 1;
	//cin >> T;
	while(T--) miss();
	//system("pause");
}

详细

Test #1:

score: 100
Accepted
time: 1ms
memory: 3792kb

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: 3536kb

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: 0ms
memory: 3532kb

input:

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

output:

Yes
1
1 3 3 4 2 
2 0 

result:

wrong output format Extra information in the output file