Submission #41572028


Source Code Expand

Copy
from itertools import combinations
from collections import defaultdict
N, M = map(int, input().split())
S = [input() for _ in range(N)]
edge = defaultdict(list)
for i, j in combinations(range(N), 2):
cnt = sum(1 for c1, c2 in zip(S[i], S[j]) if c1 != c2)
if cnt == 1:
edge[i].append(j)
edge[j].append(i)
odd = 0
eve = 0
for i in range(N):
deg = len(edge[i])
if deg == 0:
print("No")
exit()
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
from itertools import combinations
from collections import defaultdict

N, M = map(int, input().split())

S = [input() for _ in range(N)]

edge = defaultdict(list)
for i, j in combinations(range(N), 2):
  cnt = sum(1 for c1, c2 in zip(S[i], S[j]) if c1 != c2)
  if cnt == 1:
    edge[i].append(j)
    edge[j].append(i)
    
odd = 0
eve = 0
for i in range(N):
  deg = len(edge[i])
  if deg == 0:
    print("No")
    exit()
  if deg % 2:
    odd += 1
  else:
    eve += 1
    
if (odd == 0 and eve == N) or (odd == 2 and eve == N - 2):
  print("Yes")
else:
  print("No")
    







Submission Info

Submission Time
Task C - Almost Equal
User arakaki_tokyo
Language Python (3.8.2)
Score 0
Code Size 619 Byte
Status WA
Exec Time 27 ms
Memory 9264 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 250
Status
AC × 3
AC × 32
WA × 8
Set Name Test Cases
Sample example_00.txt, example_01.txt, example_02.txt
All example_00.txt, example_01.txt, example_02.txt, test_00.txt, test_01.txt, test_02.txt, test_03.txt, test_04.txt, test_05.txt, test_06.txt, test_07.txt, test_08.txt, test_09.txt, test_10.txt, test_11.txt, test_12.txt, test_13.txt, test_14.txt, test_15.txt, test_16.txt, test_17.txt, test_18.txt, test_19.txt, test_20.txt, test_21.txt, test_22.txt, test_23.txt, test_24.txt, test_25.txt, test_26.txt, test_27.txt, test_28.txt, test_29.txt, test_30.txt, test_31.txt, test_32.txt, test_33.txt, test_34.txt, test_35.txt, test_36.txt
Case Name Status Exec Time Memory
example_00.txt AC 27 ms 9076 KB
example_01.txt AC 26 ms 9228 KB
example_02.txt AC 18 ms 9224 KB
test_00.txt AC 20 ms 9132 KB
test_01.txt AC 24 ms 9092 KB
test_02.txt AC 21 ms 9084 KB
test_03.txt AC 23 ms 9224 KB
test_04.txt AC 21 ms 9128 KB
test_05.txt AC 19 ms 9220 KB
test_06.txt AC 19 ms 9072 KB
test_07.txt AC 19 ms 9084 KB
test_08.txt WA 21 ms 9228 KB
test_09.txt AC 20 ms 9224 KB
test_10.txt AC 19 ms 9076 KB
test_11.txt AC 20 ms 9188 KB
test_12.txt AC 19 ms 9088 KB
test_13.txt AC 20 ms 9180 KB
test_14.txt AC 23 ms 9088 KB
test_15.txt AC 20 ms 9128 KB
test_16.txt WA 18 ms 9184 KB
test_17.txt WA 20 ms 9084 KB
test_18.txt WA 19 ms 9220 KB
test_19.txt AC 23 ms 9072 KB
test_20.txt AC 24 ms 9132 KB
test_21.txt WA 21 ms 9180 KB
test_22.txt WA 20 ms 9092 KB
test_23.txt AC 19 ms 9088 KB
test_24.txt AC 20 ms 9264 KB
test_25.txt AC 24 ms 9088 KB
test_26.txt AC 21 ms 9132 KB
test_27.txt AC 24 ms 9128 KB
test_28.txt AC 20 ms 9136 KB
test_29.txt AC 20 ms 9188 KB
test_30.txt AC 26 ms 9192 KB
test_31.txt AC 19 ms 9224 KB
test_32.txt AC 23 ms 9128 KB
test_33.txt AC 21 ms 9148 KB
test_34.txt WA 21 ms 9180 KB
test_35.txt WA 19 ms 9228 KB
test_36.txt AC 19 ms 9188 KB


2025-04-06 (Sun)
01:00:19 +00:00