0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:48:48 +00:00

T275388 退休计划 II

https://www.luogu.com.cn/record/86998689
This commit is contained in:
Baoshuo Ren 2022-09-19 21:14:08 +08:00
parent 904ab965c5
commit 95ce0ec323
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
4 changed files with 97 additions and 0 deletions

88
Luogu/T275388/T275388.cpp Normal file
View File

@ -0,0 +1,88 @@
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>
using std::cin;
using std::cout;
const char endl = '\n';
const int N = 2e5 + 5;
int n, m;
bool vis[N];
std::vector<int> g[N], a, b;
void check() {
if (a.size() == n - a.size() - b.size()) {
std::fill_n(vis, N, false);
cout << b.size() << ' ' << a.size() << endl;
for (const int &x : b) {
cout << x << ' ';
vis[x] = true;
}
cout << endl;
for (const int &x : a) {
cout << x << ' ';
vis[x] = true;
}
cout << endl;
for (int i = 1; i <= n; i++) {
if (!vis[i]) {
cout << i << ' ';
}
}
cout << endl;
exit(0);
}
}
void dfs(int u) {
vis[u] = true;
b.emplace_back(u);
check();
for (const int &v : g[u]) {
if (vis[v]) continue;
dfs(v);
check();
}
b.pop_back();
a.emplace_back(u);
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> n >> m;
for (int i = 1; i <= m; i++) {
int u, v;
cin >> u >> v;
g[u].emplace_back(v);
g[v].emplace_back(u);
}
for (int i = 1; i <= n; i++) {
if (!vis[i]) dfs(i);
}
cout << -1 << endl;
return 0;
}

BIN
Luogu/T275388/samples/checker.cpp (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/T275388/samples/ex_king4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
Luogu/T275388/samples/ex_king4.out (Stored with Git LFS) Normal file

Binary file not shown.