結果

問題 No.1909 Detect from Substrings
ユーザー ygd.
提出日時 2022-04-22 22:44:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,050 bytes
コンパイル時間 340 ms
コンパイル使用メモリ 82,848 KB
実行使用メモリ 68,064 KB
最終ジャッジ日時 2024-06-24 04:03:57
合計ジャッジ時間 3,555 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 10 WA * 26
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
#input = sys.stdin.readline
#input = sys.stdin.buffer.readline #文字列はダメ
#sys.setrecursionlimit(1000000)
#import bisect
#import itertools
#import random
#from heapq import heapify, heappop, heappush
#from collections import defaultdict 
#from collections import deque
#import copy
#import math
#from functools import lru_cache
#@lru_cache(maxsize=None)
#MOD = pow(10,9) + 7
#MOD = 998244353
#dx = [1,0,-1,0]
#dy = [0,1,0,-1]
#dx8 = [1,1,0,-1,-1,-1,0,1]
#dy8 = [0,1,1,1,0,-1,-1,-1]

def main():
    N,M = map(int,input().split())
    S = set([])
    for i in range(N):
        s = input()
        S.add(s)

    if len(S) == 1:
        S = list(S)
        S = set(S[0])
        #print(S)
        if len(S) == 1:
            print(51)
        else:
            print(52)
        exit()
    
    if len(S) >= 3:
        print(0);exit()
    
    S = list(S)
    a = S[0]
    b = S[1]
    ans = 0
    if a[1:] == b[:-1]:
        ans += 1
    if b[1:] == a[:-1]:
        ans += 1
    print(ans)
  
if __name__ == '__main__':
    main()
0