QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#880979#9525. Welcome to Join the Online Meeting!jmyszka#WA 0ms3712kbC++173.4kb2025-02-04 06:35:042025-02-04 06:35:06

Judging History

This is the latest submission verdict.

  • [2025-02-04 06:35:06]
  • Judged
  • Verdict: WA
  • Time: 0ms
  • Memory: 3712kb
  • [2025-02-04 06:35:04]
  • Submitted

answer

#include <bits/stdc++.h>
#include <fstream>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
template<class A, class B>
ostream& operator<<(ostream& o, const pair<A, B>& p) {return o << '(' << p.first << ", " << p.second << ')';}
template<size_t Index = 0, typename... Types>
ostream& printTupleElements(ostream& o, const tuple<Types...>& t) {if constexpr (Index < sizeof...(Types)){if(Index > 0){o << ", ";}o << get<Index>(t);printTupleElements<Index + 1>(o, t);}return o;}
template<typename... Types>
ostream& operator<<(ostream& o, const tuple<Types...>& t){o << "(";printTupleElements(o, t);return o << ")";}
template<class T>
auto operator<<(ostream& o, const T& x) -> decltype(x.end(), o){o << '{';bool first = true;for (const auto& e : x){if (!first){o << ", ";}o << e;first = false;} return o << '}';}
struct custom_hash {static uint64_t splitmix64(uint64_t x) {x += 0x9e3779b97f4a7c15;x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;x = (x ^ (x >> 27)) * 0x94d049bb133111eb;return x ^ (x >> 31);}
size_t operator()(uint64_t x) const {static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();return splitmix64(x + FIXED_RANDOM);}};
//#define DEBUG
#ifdef DEBUG
#define fastio()
#define debug(x...) cerr << "[" #x "]: ", [](auto... $) {((cerr << $ << "; "), ...); }(x), cerr << '\n'
#else
#define fastio() ios_base::sync_with_stdio(0); cin.tie(0);
#define debug(...)
#endif
typedef long long ll;
#define pi pair<int, int>
#define pll pair<ll, ll>
#define st first
#define nd second
#define vi vector<int>
#define vll vector<ll>
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
void solve() {
	//ifstream cin("nazwa.in");
	//ofstream cout("nazwa.out");
	int n, m, k;
	cin >> n >> m >> k;
	vi czy(n + 1, 0);
	for(int i = 1; i <= k; i++) {
		int x;
		cin >> x;
		czy[x] = 1;
	}
	vi oj(n + 1, 0);
	iota(all(oj), 0);
	auto find = [&](auto &&find, int v) -> int {
		if(oj[v] == v) {
			return v;
		}
		return oj[v] = find(find, oj[v]);
	};
	auto uni = [&](int a, int b) {
		a = find(find, a);
		b = find(find, b);
		oj[a] = b;
	};
	vector<vi>g(n + 1), g2(n + 1);
	for(int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		//kr.eb(a, b);
		g[a].eb(b);
		g[b].eb(a);
		debug(a, b);
		if(!czy[a] && !czy[b]) {
			uni(a, b);
			g2[a].eb(b);
			g2[b].eb(a);
		}
	}
	set<int>s;
	for(int i = 1; i <= n; i++) {
		if(!czy[i]) {
			//debug(find(find, i));
			s.insert(find(find, i));
		}
	}
	if(sz(s) != 1) {
		cout << "No\n";
		return;
	}
	for(int i = 1; i <= n; i++) {
		if(czy[i]) {
			debug(i);
			bool ans = 0;
			for(auto x : g[i]) {
				debug(x);
				if(!czy[x]) {
					ans = 1;
				}
			}
			if(!ans) {
				cout << "No\n";
				return;
			}
		}
	}
	queue<int>q;
	vi vis(n + 1, 0);
	for(int i = 1; i <= n; i++) {
		if(!czy[i]) {
			q.emplace(i);
			vis[i] = 1;
		}
	}
	cout << "Yes\n";
	cout << n << '\n';
	while(!q.empty()) {
		int v = q.front();
		q.pop();
		cout << 1 << ' ' << v << '\n';
		if(!czy[v]) {
			for(auto x : g[v]) {
				if(!vis[x]) {
					vis[x] = 1;
					q.emplace(x);
				}
			}
		}
	}
	
}
int main() {
	fastio();
	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: 0ms
memory: 3712kb

input:

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

output:

Yes
4
1 1
1 2
1 3
1 4

result:

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