QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#797311 | #9525. Welcome to Join the Online Meeting! | Sword1E1 | RE | 124ms | 51092kb | C++20 | 1.8kb | 2024-12-02 20:35:36 | 2024-12-02 20:35:38 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define dbg(x...) \
do { \
std::cout << #x << " -> "; \
err(x); \
} while (0)
void err() {
std::cout << std::endl;
}
template<class T, class... Ts>
void err(T arg, Ts &... args) {
std::cout << fixed << setprecision(10) << arg << ' ';
err(args...);
}
const int maxn = 2e5 + 5;
vector <int> g[maxn];
int ok[maxn],vis[maxn];
void dfs(int u,int f) {
ok[u] = 1;
if (vis[u]) return ;
for (auto i : g[u]) {
if (i == f) continue;
if (ok[i]) continue;
dfs(i,u);
}
}
vector <vector <int>> ans;
void find_path(int u,int f) {
ok[u] = 1;
if (vis[u]) return ;
vector <int> res;
vector <int> val;
for (auto i : g[u]) {
if (i == f) continue;
if (ok[i]) continue;
val.push_back(i);
find_path(i,u);
}
if (!val.empty()) {
res.push_back(u);
res.push_back((int)val.size());
for (auto i : val) res.push_back(i);
ans.push_back(res);
}
}
void GENSHEN_START() {
int n,m,k;cin >> n >> m >> k;
for (int i = 1;i <= k;i++) {
int x;cin >> x;
vis[x] = 1;
}
if (k == 0) getchar();
for (int i = 1;i <= m;i++) {
int u,v;cin >> u >> v;
g[u].push_back(v);
g[v].push_back(u);
}
int p;
for (int i = 1;i <= m;i++) {
if (!vis[i]) {
p = i;
dfs(i,0);
break;
}
}
for (int i = 1;i <= n;i++) {
if (ok[i] == 0) {
cout << "No" << '\n';
return ;
}
}
cout << "Yes" << '\n';
for (int i = 1;i <= n;i++) ok[i] = 0;
find_path(p,0);
int len = ans.size();
cout << len << '\n';
for (int i = len - 1;i >= 0;i--) {
for (auto j : ans[i]) {
cout << j << ' ';
}
cout << '\n';
}
}
signed main()
{
ios::sync_with_stdio(false);cin.tie(nullptr);
int T = 1;
//cin >> T;
while (T--) GENSHEN_START();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 5640kb
input:
4 5 2 3 4 1 2 1 3 2 3 3 4 2 4
output:
Yes 2 1 1 2 2 2 3 4
result:
ok ok
Test #2:
score: 0
Accepted
time: 1ms
memory: 3588kb
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: 5632kb
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: 5864kb
input:
6 6 0 1 2 2 3 3 1 4 5 5 6 6 4
output:
No
result:
ok ok
Test #5:
score: 0
Accepted
time: 111ms
memory: 51092kb
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 178679 1 186222 186222 1 122914 122914 1 18533 18533 1 66240 66240 1 143831 143831 1 52965 52965 1 45501 45501 1 36293 36293 1 95051 95051 1 114707 114707 1 90623 90623 1 10911 10911 1 1942 1942 1 41382 41382 1 188734 188734 1 107093 107093 1 154956 1549...
result:
ok ok
Test #6:
score: 0
Accepted
time: 124ms
memory: 50680kb
input:
199999 199998 1 136702 159826 166341 166341 59559 59559 169672 169672 102084 102084 136269 136269 57057 57057 59116 59116 119963 119963 85663 85663 33942 33942 84604 84604 189395 189395 154906 154906 22175 22175 144902 144902 198523 198523 35993 35993 35690 35690 47504 47504 104458 104458 68253 6825...
output:
Yes 199997 1 2 172082 191801 191801 1 65736 65736 1 10794 10794 1 50503 50503 1 194943 194943 1 42759 42759 1 35447 35447 1 55027 55027 1 175222 175222 1 103541 103541 1 104528 104528 1 21620 21620 1 141581 141581 1 74591 74591 1 43436 43436 1 42438 42438 1 84592 84592 1 29722 2972...
result:
ok ok
Test #7:
score: -100
Runtime Error
input:
199998 199997 0 67665 130538 130538 101337 101337 73749 73749 138128 138128 1274 1274 108069 108069 50961 50961 7039 7039 109946 109946 170551 170551 193330 193330 113590 113590 92775 92775 2146 2146 43591 43591 125033 125033 75583 75583 173991 173991 46820 46820 3986 3986 163272 163272 91657 91657...