QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#797293 | #9525. Welcome to Join the Online Meeting! | Sword1E1 | WA | 1ms | 5600kb | C++20 | 1.7kb | 2024-12-02 20:23:20 | 2024-12-02 20:23:22 |
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;
res.push_back(u);
vector <int> val;
for (auto i : g[u]) {
if (i == f) continue;
if (ok[i]) continue;
val.push_back(i);
find_path(i,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;
}
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: 1ms
memory: 3560kb
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: 3848kb
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: 1ms
memory: 5600kb
input:
4 6 2 3 4 1 3 1 4 2 3 2 4 1 2 3 4
output:
Yes 2 1 3 3 4 2 2 0
result:
wrong answer Integer parameter [name=y_j] equals to 0, violates the range [1, 4]