A12872 | Swiper, no swiping!
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
I'm the Map, I'm the Map! I'm the MAP!!!
Map
In anticipation of new adventures Boots wanted to do a good deed. After discussion with the Map and Backpack, they decided to gift Dora a connected graph. After a long search, Boots chose $t$ graph's variants, which Dora might like. However fox Swiper wants to spoil his plan.
The Swiper knows, that Dora now is only able to count up to $3$ , so he has came up with a following idea. He wants to steal some non-empty set of vertices, so that the Dora won't notice the loss. He has decided to steal some non-empty set of vertices, so that after deletion of the stolen vertices and edges adjacent to them, every remaining vertex wouldn't change it's degree modulo $3$ . The degree of a vertex is the number of edges it is adjacent to. It would've been suspicious to steal all the vertices, so Swiper needs another plan.
Boots are sure, that the crime can not be allowed. However they are afraid, that they won't be able to handle this alone. So Boots decided to ask for your help. Please determine for every graph's variant whether the Swiper can perform the theft or not.
Map
In anticipation of new adventures Boots wanted to do a good deed. After discussion with the Map and Backpack, they decided to gift Dora a connected graph. After a long search, Boots chose $t$ graph's variants, which Dora might like. However fox Swiper wants to spoil his plan.
The Swiper knows, that Dora now is only able to count up to $3$ , so he has came up with a following idea. He wants to steal some non-empty set of vertices, so that the Dora won't notice the loss. He has decided to steal some non-empty set of vertices, so that after deletion of the stolen vertices and edges adjacent to them, every remaining vertex wouldn't change it's degree modulo $3$ . The degree of a vertex is the number of edges it is adjacent to. It would've been suspicious to steal all the vertices, so Swiper needs another plan.
Boots are sure, that the crime can not be allowed. However they are afraid, that they won't be able to handle this alone. So Boots decided to ask for your help. Please determine for every graph's variant whether the Swiper can perform the theft or not.
输入格式
The first line contains a single integer $t$ ( $1 \le t \le 100\,000$ ) — the number of graph variants.
The first line of each variant contains integers $n$ , $m$ ( $1 \le n \le 500\,000$ , $0 \le m \le 500\,000$ ), the number of vertexes and edges in the graph.
Then $m$ lines follow, each containing integers $a_i$ , $b_i$ ( $1 \le a_i, b_i \le n$ ), the indices of the vertices connected with a corresponding edge.
It's guaranteed, that the graph is connected and doesn't contain multiple edges or self-loops.
It's guaranteed, that the sum of $n$ over all variants is at most $500\,000$ and that the sum of $m$ over all variants is at most $500\,000$ .
Descriptions of graph's variants are separated with an empty line.
The first line of each variant contains integers $n$ , $m$ ( $1 \le n \le 500\,000$ , $0 \le m \le 500\,000$ ), the number of vertexes and edges in the graph.
Then $m$ lines follow, each containing integers $a_i$ , $b_i$ ( $1 \le a_i, b_i \le n$ ), the indices of the vertices connected with a corresponding edge.
It's guaranteed, that the graph is connected and doesn't contain multiple edges or self-loops.
It's guaranteed, that the sum of $n$ over all variants is at most $500\,000$ and that the sum of $m$ over all variants is at most $500\,000$ .
Descriptions of graph's variants are separated with an empty line.
输出格式
For each variant:
- In case the answer exists, print "Yes" and then the answer itself.The first line should contain an integer $c$ ( $1 < c < n$ ), the number of vertices the Crook can steal, without Dora noticing the loss. On the next line print $c$ distinct integers, the indices of the graph's vertices in arbitrary order.
- Otherwise print "No".
In case there are several correct ways to steal the vertices, print any of them.
Please note, that it's not required to maximize the number of stolen vertices.
- In case the answer exists, print "Yes" and then the answer itself.The first line should contain an integer $c$ ( $1 < c < n$ ), the number of vertices the Crook can steal, without Dora noticing the loss. On the next line print $c$ distinct integers, the indices of the graph's vertices in arbitrary order.
- Otherwise print "No".
In case there are several correct ways to steal the vertices, print any of them.
Please note, that it's not required to maximize the number of stolen vertices.
输入输出样例
输入 #1
3 3 3 1 2 2 3 3 1 6 6 1 2 1 3 2 3 2 5 2 6 2 4 8 12 1 2 1 3 2 3 1 4 4 5 5 1 3 6 3 7 3 8 6 1 7 1 8 1
输出 #1
No Yes 3 4 5 6 Yes 3 6 7 8
The picture below shows the third variant from the example test. The set of the vertices the Crook can steal is denoted with bold.


C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted