CF461D.Appleman and Complicated Task
省选/NOI-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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 (109 + 7). Two cells of the board are adjacent if they share a side.
Toastman 提出了一个非常复杂的问题。他将这个问题交给了 Appleman,但 Appleman 不知道如何解决它。你能帮他吗?
给定一个 n×n 的棋盘。棋盘的每个格子中要么是字符 'x',要么是字符 'o',要么为空。问:有多少种方式将所有空格子填上 'x' 或 'o'(每个格子最终必须恰好包含一个字符),使得对每个格子而言,与其相邻(即共享一条边)且填有 'o' 的格子数目为偶数?答案对 1000000007(即 109+7)取模。
输入格式
The first line contains two integers n, k (1 ≤ n, k ≤ 105) — 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.
第一行包含两个整数 n、k(1≤n,k≤105)—— 分别表示棋盘的大小以及初始时含有字符的格子数量。
接下来是 k 行。第 i 行包含两个整数和一个字符:ai、bi、ci(1≤ai,bi≤n;ci 为 'o' 或 'x')。该行表示:在第 ai 行与第 bi 列相交的格子中,存在字符 ci。所有给出的格子互不相同。
注意:行号从上到下依次编号为 1 至 n;列号从左到右依次编号为 1 至 n。
输出格式
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:
xxo xoo
xox ooo
oxx oox
在第一个例子中,有两种方式:
xxo xoo
xox ooo
oxx oox
输入解题思路,AI测评打分。不知道怎么写?