惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

宝玉的分享
宝玉的分享
酷 壳 – CoolShell
酷 壳 – CoolShell
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
S
Security @ Cisco Blogs
小众软件
小众软件
D
Docker
博客园_首页
A
About on SuperTechFans
P
Privacy International News Feed
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
A
Arctic Wolf
Spread Privacy
Spread Privacy
有赞技术团队
有赞技术团队
T
Tailwind CSS Blog
Latest news
Latest news
WordPress大学
WordPress大学
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Exploit Database - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
大猫的无限游戏
大猫的无限游戏
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
K
Kaspersky official blog
V2EX - 技术
V2EX - 技术
SecWiki News
SecWiki News
U
Unit 42
GbyAI
GbyAI
H
Hackread – Cybersecurity News, Data Breaches, AI and More
L
LINUX DO - 热门话题
S
Security Affairs
Y
Y Combinator Blog
aimingoo的专栏
aimingoo的专栏
Blog — PlanetScale
Blog — PlanetScale
MongoDB | Blog
MongoDB | Blog
博客园 - 【当耐特】
The GitHub Blog
The GitHub Blog
T
Tenable Blog
W
WeLiveSecurity
Cloudbric
Cloudbric
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
G
Google Developers Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
N
Netflix TechBlog - Medium
F
Full Disclosure
N
News and Events Feed by Topic
D
DataBreaches.Net
P
Proofpoint News Feed
B
Blog RSS Feed
B
Blog
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org

Tifa's Blog

随笔 - 关于 C++ 模板的部分特化 随笔 - Miller-Rabin + Pollard-Rho 分解质因子的时间复杂度分析 随笔 - 批量重命名 APK 文件的 Python 脚本 VP 记录 - 2021 CCPC 哈尔滨站 VP 记录 - 2023 ICPC 亚洲区域赛 (南京) VP 记录 - 2023 CCPC 桂林站 VP 记录 - 2023 ICPC 亚洲区域赛 (网络预选赛 Ⅰ) VP 记录 - 2021 ICPC 亚洲区域赛 (澳门) 题解 - [Luogu P7486] 「Stoi2031」彩虹 拟阵简介(unfin) 题解 - [Luogu P5824] 十二重计数法 随笔 - C++ 的高维向量 | Tifa's Blog 目录 - 算法竞赛模板 | Tifa's Blog 目录 - 学术垃圾 | Tifa's Blog 比赛记录 - Codeforces Round #842 (Div. 2) 比赛记录 - Hello 2023 | Tifa's Blog 比赛记录 - Codeforces Round #841 (Div. 2) and Divide by Zero 2022 随笔 - C++ 基于标签分发的线性筛 | Tifa's Blog VP 记录 - 2022 ICPC 亚洲区域赛 (杭州) VP 记录 - 2022 ICPC 亚洲区域赛 (济南)
VP 记录 - 2023 CCPC 哈尔滨站
Tifa · 2023-11-24 · via Tifa's Blog
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <bits/stdc++.h>
using namespace std;
template <class Tp>
using vec = vector<Tp>;
template <class... Ts>
void dec(Ts &...x) {
((--x), ...);
}
template <class... Ts>
void inc(Ts &...x) {
((++x), ...);
}
void solve(int t_ = 0) {
int n, m;
cin >> n >> m;
vector<vec<int>> e(n);
auto add = [&](int u, int v) { e[u].push_back(v), e[v].push_back(u); };
for (int i = 0, u, v; i < m; ++i) cin >> u >> v, --u, --v, add(u, v);
int sg = 0;
vector<int> rt, sz(n);
auto dfs = [&](auto dfs, int u) -> void {
sz[u] = 1;
for (auto v : e[u])
if (!sz[v]) dfs(dfs, v), sz[u] += sz[v];
};
auto ssg = [](int x) {
if (!x) return 0;
return x & 1 ? 1 : 2;
};
for (int i = 0; i < n; ++i)
if (!sz[i]) {
dfs(dfs, i), rt.push_back(i);
sg ^= ssg(sz[i]);
}
if (!sg) return void(cout << 0);
int ans = 0;
auto getans = [&](auto getans, int u, int fa, int ssz) -> void {
int t = ssg(ssz - sz[u]);
for (auto v : e[u])
if (v != fa) {
if (0 == (sg ^ (ssg(sz[v]) ^ ssg(ssz - sz[v])))) ++ans;
getans(getans, v, u, ssz);
t ^= ssg(sz[v]);
}
if (0 == (sg ^ t)) ++ans;
};
for (auto x : rt) {
sg ^= ssg(sz[x]);
getans(getans, x, x, sz[x]);
sg ^= ssg(sz[x]);
}
cout << ans;
}
signed main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cerr << fixed << setprecision(6);
int i_ = 0;
solve(i_);
return 0;
}