mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-08 13:18:46 +00:00
1098. [POI2007]办公楼biu
https://hydro.ac/d/bzoj/record/6322c18cbdf9bc31d1607532
This commit is contained in:
parent
4a3a25865d
commit
8f07b5e70f
81
BZOJ/1098/1098.cpp
Normal file
81
BZOJ/1098/1098.cpp
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
#include <iostream>
|
||||||
|
#include <algorithm>
|
||||||
|
#include <queue>
|
||||||
|
#include <set>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
using std::cin;
|
||||||
|
using std::cout;
|
||||||
|
const char endl = '\n';
|
||||||
|
|
||||||
|
const int N = 1e5 + 5;
|
||||||
|
|
||||||
|
int n, m, cnt, ans[N];
|
||||||
|
std::vector<int> g[N];
|
||||||
|
std::set<int> set;
|
||||||
|
bool vis[N];
|
||||||
|
|
||||||
|
void bfs(int x) {
|
||||||
|
std::queue<int> q;
|
||||||
|
|
||||||
|
set.erase(x);
|
||||||
|
q.push(x);
|
||||||
|
ans[cnt]++;
|
||||||
|
|
||||||
|
while (!q.empty()) {
|
||||||
|
int u = q.front();
|
||||||
|
q.pop();
|
||||||
|
vis[u] = true;
|
||||||
|
|
||||||
|
for (auto it = set.begin(); it != set.end();) {
|
||||||
|
int v = *it;
|
||||||
|
|
||||||
|
if (*std::lower_bound(g[u].begin(), g[u].end(), v) != v) {
|
||||||
|
q.push(v);
|
||||||
|
ans[cnt]++;
|
||||||
|
set.erase(it++);
|
||||||
|
} else {
|
||||||
|
it++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
std::ios::sync_with_stdio(false);
|
||||||
|
cin.tie(nullptr);
|
||||||
|
|
||||||
|
cin >> n >> m;
|
||||||
|
|
||||||
|
for (int i = 1, u, v; i <= m; i++) {
|
||||||
|
cin >> u >> v;
|
||||||
|
|
||||||
|
g[u].push_back(v);
|
||||||
|
g[v].push_back(u);
|
||||||
|
}
|
||||||
|
|
||||||
|
std::for_each(g + 1, g + n + 1, [&](auto& v) { std::sort(v.begin(), v.end()); });
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
set.insert(i);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (int i = 1; i <= n; i++) {
|
||||||
|
if (!vis[i]) {
|
||||||
|
cnt++;
|
||||||
|
bfs(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::sort(ans + 1, ans + 1 + cnt);
|
||||||
|
|
||||||
|
cout << cnt << endl;
|
||||||
|
|
||||||
|
for (int i = 1; i <= cnt; i++) {
|
||||||
|
cout << ans[i] << ' ';
|
||||||
|
}
|
||||||
|
|
||||||
|
cout << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
BIN
BZOJ/1098/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/11.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/11.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/11.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/11.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/12.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/12.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/12.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/12.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/13.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/13.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/13.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/13.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/14.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/14.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/14.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/14.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/15.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/15.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/15.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/15.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/1098/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/1098/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user