A9637 | Appleman and Complicated Task
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Toastman came up with a very complicated task. He gives it to Appleman, but Appleman doesn't know how to solve it. Can you help him?
Given a $n×n$ checkerboard. Each cell of the board has either character 'x', or character 'o', or nothing. How many ways to fill all the empty cells with 'x' or 'o' (each cell must contain only one character in the end) are there, such that for each cell the number of adjacent cells with 'o' will be even? Find the number of ways modulo $1000000007$ $(10^{9}+7)$ . Two cells of the board are adjacent if they share a side.
Given a $n×n$ checkerboard. Each cell of the board has either character 'x', or character 'o', or nothing. How many ways to fill all the empty cells with 'x' or 'o' (each cell must contain only one character in the end) are there, such that for each cell the number of adjacent cells with 'o' will be even? Find the number of ways modulo $1000000007$ $(10^{9}+7)$ . Two cells of the board are adjacent if they share a side.
输入格式
The first line contains two integers $n$ , $k$ ( $1<=n,k<=10^{5}$ ) — the size of the board, and the number of cells that has characters initially.
Then $k$ lines follows. The $i$ -th line contains two integers and a character: $a_{i}$ , $b_{i}$ , $c_{i}$ ( $1<=a_{i},b_{i}<=n$ ; $c_{i}$ is either 'o' or 'x'). This line means: there is a character $c_{i}$ in the cell that is located on the intersection of the $a_{i}$ -th row and $b_{i}$ -th column. All the given cells are distinct.
Consider that the rows are numbered from $1$ to $n$ from top to bottom. Analogically, the columns are numbered from $1$ to $n$ from left to right.
Then $k$ lines follows. The $i$ -th line contains two integers and a character: $a_{i}$ , $b_{i}$ , $c_{i}$ ( $1<=a_{i},b_{i}<=n$ ; $c_{i}$ is either 'o' or 'x'). This line means: there is a character $c_{i}$ in the cell that is located on the intersection of the $a_{i}$ -th row and $b_{i}$ -th column. All the given cells are distinct.
Consider that the rows are numbered from $1$ to $n$ from top to bottom. Analogically, the columns are numbered from $1$ to $n$ from left to right.
输出格式
Print a single integer — the answer to the problem.
输入输出样例
输入 #1
3 2 1 1 x 2 2 o
输出 #1
2
输入 #2
4 3 2 4 x 3 4 x 3 2 x
输出 #2
2
In the first example there are two ways:
<br></br> xxo xoo<br></br> xox ooo<br></br> oxx oox<br></br>
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted