POJ 1733 Parity Game
来源:互联网 发布:淘宝三心要几个好评 编辑:程序博客网 时间:2024/04/30 09:16
Parity game
Time Limit: 1000MS Memory Limit: 65536KTotal Submissions: 2426 Accepted: 992
Description
Now and then you play the following game with your friend. Your friend writes down a sequence consisting of zeroes and ones. You choose a continuous subsequence (for example the subsequence from the third to the fifth digit inclusively) and ask him, whether this subsequence contains even or odd number of ones. Your friend answers your question and you can ask him about another subsequence and so on. Your task is to guess the entire sequence of numbers.
You suspect some of your friend's answers may not be correct and you want to convict him of falsehood. Thus you have decided to write a program to help you in this matter. The program will receive a series of your questions together with the answers you have received from your friend. The aim of this program is to find the first answer which is provably wrong, i.e. that there exists a sequence satisfying answers to all the previous questions, but no such sequence satisfies this answer.
You suspect some of your friend's answers may not be correct and you want to convict him of falsehood. Thus you have decided to write a program to help you in this matter. The program will receive a series of your questions together with the answers you have received from your friend. The aim of this program is to find the first answer which is provably wrong, i.e. that there exists a sequence satisfying answers to all the previous questions, but no such sequence satisfies this answer.
Input
The first line of input contains one number, which is the length of the sequence of zeroes and ones. This length is less or equal to 1000000000. In the second line, there is one positive integer which is the number of questions asked and answers to them. The number of questions and answers is less or equal to 5000. The remaining lines specify questions and answers. Each line contains one question and the answer to this question: two integers (the position of the first and last digit in the chosen subsequence) and one word which is either `even' or `odd' (the answer, i.e. the parity of the number of ones in the chosen subsequence, where `even' means an even number of ones and `odd' means an odd number).
Output
There is only one line in output containing one integer X. Number X says that there exists a sequence of zeroes and ones satisfying first X parity conditions, but there exists none satisfying X+1 conditions. If there exists a sequence of zeroes and ones satisfying all the given conditions, then number X should be the number of all the questions asked.
Sample Input
1051 2 even3 4 odd5 6 even1 6 even7 10 odd
Sample Output
3
Source
CEOI 1999
- POJ 1733 Parity Game
- poj 1733 parity game
- POJ 1733 Parity game
- poj 1733 Parity game
- poj 1733 Parity game
- POJ-1733-Parity game
- poj 1733 Parity game
- POJ 1733 Parity game
- poj 1733 Parity game
- POJ 1733 Parity game
- POJ 1733 Parity game
- POJ-1733Parity game
- POJ 1733Parity game
- POJ 1733 Parity game 笔记
- POJ 1733 Parity game(并查集)
- POJ 1733 Parity game (并查集)
- 【POJ】1733 Parity game 并查集
- poj-1733 Parity game 并查集
- ld.so.conf 文件与PKG_CONFIG_PATH变量-ZT
- 魔兽世界私服trinitycore2的架构(8)脚本
- SMT加工 宝安SMT加工 深圳SMT加工 石岩SMT加工 西丽SMT加工
- Spring中常用的hql查询方法(getHibernateTemplate())
- 实时滚动进度的实现
- POJ 1733 Parity Game
- Android SDK1.5 模拟器 快捷键
- 为PHP添加mcrypt扩展模块
- IE9初窥:支持CSS3,和HTML5?
- OpenCms TemplateTwo 汉化模块修正版发布
- 对话大学生--李开复
- vmlinuz,initrd,system.map文件
- Linux 进程管理
- Hibernate HQL 语法大全 查询技巧