QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#760880 | #9525. Welcome to Join the Online Meeting! | 123adad | WA | 101ms | 25108kb | C++20 | 2.0kb | 2024-11-18 19:56:48 | 2024-11-18 19:56:48 |
Judging History
answer
#include <bits/stdc++.h>
#define rep(i, j, k) for(int i=(j);i<=(k);++i)
#define per(i, j, k) for(int i=(j);i>=(k);--i)
#define mem(a, b) memset(a,b,sizeof(a))
#define pii pair<int,int>
#define sz(x) (int)(x).size()
#define lson (p<<1)
#define rson (p<<1|1)
#define int long long
#define pb push_back
#define eb emplace_back
#define enter putchar('\n')
#define space putchar(' ')
#define yes "Yes"
#define no "No"
const int mod=998244353, N=2e5+5, INF=0x3f3f3f3f3f3f3f3f;
using namespace std;
inline int read() {
int x = 0, f = 1;
char c = getchar();
while (c < '0' || c > '9') f = c == '-' ? -1 : f, c = getchar();
while (c >= '0' && c <= '9') x = (x<<3)+(x<<1)+(c^48), c = getchar();
return x*f;
}
inline void write(int x) {
if (x < 0) x = -x, putchar('-');
if (x > 9) write(x/10);
putchar('0' + x%10);
}
vector<int> e[N];
void solve() {
int n = read(), m = read(), k = read();
set<int> s;
rep(i, 1, k) s.insert(read());
rep(i, 1, m) {
int p = read(), q = read();
if (!s.count(p) && !s.count(q))
e[q].pb(p), e[p].pb(q);
else if (s.count(p) && !s.count(q))
e[q].pb(p);
else if (s.count(q) && !s.count(p))
e[p].pb(q);
}
vector<vector<int>> ans(n + 1);
vector<bool> vis(n + 1);
queue<int> q;
rep(i, 1, n)
if (!s.count(i)) {
q.push(i);
vis[i] = true;
break;
}
int t = 0;
while(!q.empty()) {
int u = q.front();
q.pop();
for(auto& v: e[u]) {
if (!vis[v]) {
vis[v] = true;
q.push(v);
ans[u].pb(v);
}
}
if (sz(ans[u])) t ++;
}
rep(i, 1, n) {
if (!vis[i]) {
puts(no);
return;
}
}
puts(yes);
write(t), enter;
rep(i, 1, n) {
if (sz(ans[i])) {
write(i), space;
write(sz(ans[i])), space;
for(auto& v: ans[i]) {
write(v), space;
}
enter;
}
}
}
signed main() {
int t = 1;
//t = read();
while(t --) {
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3552kb
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: 1ms
memory: 3812kb
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: 0
Accepted
time: 1ms
memory: 3584kb
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
result:
ok ok
Test #4:
score: 0
Accepted
time: 1ms
memory: 3520kb
input:
6 6 0 1 2 2 3 3 1 4 5 5 6 6 4
output:
No
result:
ok ok
Test #5:
score: -100
Wrong Answer
time: 101ms
memory: 25108kb
input:
200000 199999 2 142330 49798 49798 116486 116486 64386 64386 192793 192793 61212 61212 138489 138489 83788 83788 89573 89573 8596 8596 156548 156548 41800 41800 14478 14478 27908 27908 82806 82806 9353 9353 160166 160166 92308 92308 36265 36265 126943 126943 190578 190578 191148 191148 177381 177381...
output:
Yes 199998 1 2 95113 178679 2 1 198122 3 1 41738 4 1 196324 5 1 91673 6 1 796 7 1 136018 8 1 100182 9 1 101606 10 1 73864 11 1 105951 12 1 63827 13 1 130553 14 1 177897 15 1 196567 16 1 92389 17 1 72182 18 1 141202 19 1 45379 20 1 114057 21 1 105287 22 1 7260 23 1 40268 24 1 5...
result:
wrong answer on step #2, member 2 is not invited before inviting others