luogu#P3552. [POI2013] SPA-Walk
[POI2013] SPA-Walk
题目描述
The names of towns in Byteotia are unique sequences of exactly bits.
There are towns in Byteotia, and thus,only sequences of 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 to the town , taking the existing roads.
Your task is to write a program that will determine if such a walk is possible.
有2^n个长度为n的01串,两个01串之间有边当且仅当这两个01串只有一位不同,现在从这2n个串中拿掉k个,问指定两个串之间能否到达
输入格式
In the first line of the standard input, there are two integers, and (, , , ), separated by a single space.
These are the length of town names in bits and the the number of -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 and .
In the lines that follow, all the sequences of bits that do not correspond to any town are given, one sequence per line.In the lines that follow, all the sequences of bits that do not correspond to any town are given, one sequence per line.Each such sequence is a string of characters 0 and/or 1.You may assume that and are not among those 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
提示
有2^n个长度为n的01串,两个01串之间有边当且仅当这两个01串只有一位不同,现在从这2n个串中拿掉k个,问指定两个串之间能否到达