当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

BZOJ3421:Poi2013 Walk

题目描述

The names of towns in Byteotia are unique sequences of exactly N  bits. There are 2^N – k towns in Byteotia, and thus, only K sequences of N  bits do not correspond to any town.
Some pairs of towns are connected with roads. Specifically, two towns are directly linked by a road if and only if their names differ in a single bit. The roads do not cross outside of towns.
Byteasar intends to take a stroll - he intends to walk from the town x  to the town y , taking the existing roads. Your task is to write a program that will determine if such a walk is possible.

有2^N-k个点,每个点有一个独一无二的、长度为n的01串,但是有k个01串没有出现过。每两个点之间有连边当且仅当两个01串之间有且仅有一个位置是不同的。现在询问x和y两个字符串能不能互相到达

输入解释

In the first line of the standard input, there are two integers, N  and K (1<=N<=60,0<=K<=1000000,k<=2^N-1, N*k<=5000000)  separated by a single space. These are the length of town names in bits and the the number of N -bit sequences that do not correspond to any town, respectively. In the second line, there are two strings, separated by a single space, each consisting of   characters 0 and/or 1. These are the names of the towns x and y. In the K lines that follow, all the sequences of N bits that do not correspond to any town are given, one sequence per line. Each such sequence is a string of   characters 0 and/or1. You may assume that x  and  y  are not among those K sequences.

输出解释

Your program should print to the standard output the word TAK (Polish for yes) if walking from the town x to the town y  is possible, and the word NIE (Polish for no) otherwise.

输入样例
4 6
0000 1011
0110
0111
0011
1101
1010
1001
输出样例
TAK

该题目包含在题集 大视野(八中)OJ 中

题目来源 BZOJ 3421

源链接: LOCAL-BZOJ3421

共提交 0 次

通过率 --%
时间上限 内存上限
100000 MS 256 MB