868C - Qualification Rounds - CodeForces Solution


bitmasks brute force constructive algorithms dp *1500

Please click on ads to support us..

Python Code:

def str2i(line):
	nums = [int(x) for x in line.split()]
	v = 0
	for i in nums:
		v <<= 1
		v |= i
	
	return v

def inverse(n, k):
	v = 0
	pow2 = [1<<i for i in range(k)]
	for i in pow2:
		if (n & i) == 0:
			v |= i
	
	return v


n, k = [int(x) for x in input().split()]
cc = [0 for i in range(16)]
for i in range(n):
	cc[str2i(input())] += 1


possible = False

for i in range(16):
	if cc[i] == 0:
		continue
	for j in range(16):
		if cc[j] == 0:
			continue
		if (i & j) == 0:
			possible = True
			break
	
	if possible:
		break

if possible:
	print('YES')
else:
	print('NO')
			


Comments

Submit
0 Comments
More Questions

32. Longest Valid Parentheses
Cutting a material
Bubble Sort
Number of triangles
AND path in a binary tree
Factorial equations
Removal of vertices
Happy segments
Cyclic shifts
Zoos
Build a graph
Almost correct bracket sequence
Count of integers
Differences of the permutations
Doctor's Secret
Back to School
I am Easy
Teddy and Tweety
Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement