Submission #49502514
Source Code Expand
#再帰はCpython,その他はpypy import sys sys.setrecursionlimit(1000000) from collections import deque H, W, K = map(int, input().split()) S = [] ans = 10 ** 6 S1 = [[] for _ in range(W)] for i in range(H): tem = str(input()) tem = list(tem) for j in range(W): S1[j].append(tem[j]) S.append(tem) #print(S) #print(S1) def check(l, zyougen): #print(zyougen) global ans que = deque() batu = 0 maru = 0 ten = 0 #print(l) if len(l) < K: return 0 else: for i in range(K): if l[i] == "x": batu += 1 elif l[i] == "o": maru += 1 elif l[i] == ".": ten += 1 que.append(l[i]) #print(que) if batu == 0: ans = min(ten, ans) #print(que, ans) for i in range(K,zyougen): #print(i) outt = que.popleft() inn = l[i] que.append(inn) if outt == "x": batu -= 1 elif outt == "o": maru -= 1 elif outt== ".": ten -= 1 if inn == "x": batu += 1 elif inn == "o": maru += 1 elif inn == ".": ten += 1 if batu == 0: ans = min(ten, ans) #print(ans, que) for i in range(H): if W >= K: check(S[i],W) for i in range(W): if H >= K: check(S1[i],H) if ans == 10**6: print(-1) else: print(ans)
Submission Info
Submission Time | |
---|---|
Task | D - Cheating Gomoku Narabe |
User | habuyossyaru |
Language | Python (CPython 3.11.4) |
Score | 400 |
Code Size | 1671 Byte |
Status | AC |
Exec Time | 308 ms |
Memory | 32812 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 400 / 400 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.txt, example2.txt, example3.txt |
All | 000.txt, 001.txt, 002.txt, 003.txt, 004.txt, 005.txt, 006.txt, 007.txt, 008.txt, 009.txt, 010.txt, 011.txt, 012.txt, 013.txt, 014.txt, 015.txt, 016.txt, 017.txt, 018.txt, 019.txt, 020.txt, 021.txt, 022.txt, 023.txt, 024.txt, 025.txt, 026.txt, 027.txt, 028.txt, 029.txt, 030.txt, 031.txt, 032.txt, 033.txt, 034.txt, 035.txt, 036.txt, 037.txt, 038.txt, 039.txt, 040.txt, 041.txt, 042.txt, 043.txt, 044.txt, 045.txt, 046.txt, 047.txt, 048.txt, 049.txt, 050.txt, 051.txt, 052.txt, 053.txt, 054.txt, 055.txt, 056.txt, 057.txt, 058.txt, 059.txt, 060.txt, 061.txt, 062.txt, example0.txt, example1.txt, example2.txt, example3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 12 ms | 9344 KiB |
001.txt | AC | 12 ms | 9364 KiB |
002.txt | AC | 12 ms | 9424 KiB |
003.txt | AC | 109 ms | 32812 KiB |
004.txt | AC | 127 ms | 32048 KiB |
005.txt | AC | 127 ms | 31984 KiB |
006.txt | AC | 125 ms | 32028 KiB |
007.txt | AC | 280 ms | 29876 KiB |
008.txt | AC | 305 ms | 28880 KiB |
009.txt | AC | 300 ms | 28972 KiB |
010.txt | AC | 308 ms | 28896 KiB |
011.txt | AC | 85 ms | 13032 KiB |
012.txt | AC | 73 ms | 13556 KiB |
013.txt | AC | 50 ms | 13220 KiB |
014.txt | AC | 90 ms | 14012 KiB |
015.txt | AC | 51 ms | 12964 KiB |
016.txt | AC | 76 ms | 13632 KiB |
017.txt | AC | 86 ms | 15580 KiB |
018.txt | AC | 112 ms | 13596 KiB |
019.txt | AC | 51 ms | 12976 KiB |
020.txt | AC | 93 ms | 13988 KiB |
021.txt | AC | 132 ms | 13148 KiB |
022.txt | AC | 84 ms | 13860 KiB |
023.txt | AC | 50 ms | 13748 KiB |
024.txt | AC | 83 ms | 13424 KiB |
025.txt | AC | 80 ms | 12956 KiB |
026.txt | AC | 80 ms | 12704 KiB |
027.txt | AC | 81 ms | 13336 KiB |
028.txt | AC | 110 ms | 12980 KiB |
029.txt | AC | 68 ms | 13152 KiB |
030.txt | AC | 61 ms | 13300 KiB |
031.txt | AC | 77 ms | 13456 KiB |
032.txt | AC | 48 ms | 13664 KiB |
033.txt | AC | 74 ms | 13068 KiB |
034.txt | AC | 57 ms | 13504 KiB |
035.txt | AC | 84 ms | 13236 KiB |
036.txt | AC | 51 ms | 13040 KiB |
037.txt | AC | 77 ms | 14412 KiB |
038.txt | AC | 49 ms | 13080 KiB |
039.txt | AC | 85 ms | 13152 KiB |
040.txt | AC | 56 ms | 13472 KiB |
041.txt | AC | 78 ms | 13456 KiB |
042.txt | AC | 51 ms | 13148 KiB |
043.txt | AC | 79 ms | 13164 KiB |
044.txt | AC | 49 ms | 13516 KiB |
045.txt | AC | 78 ms | 12832 KiB |
046.txt | AC | 67 ms | 13608 KiB |
047.txt | AC | 48 ms | 12896 KiB |
048.txt | AC | 76 ms | 13080 KiB |
049.txt | AC | 47 ms | 12936 KiB |
050.txt | AC | 77 ms | 13120 KiB |
051.txt | AC | 49 ms | 13296 KiB |
052.txt | AC | 82 ms | 13224 KiB |
053.txt | AC | 50 ms | 12884 KiB |
054.txt | AC | 82 ms | 13196 KiB |
055.txt | AC | 50 ms | 12924 KiB |
056.txt | AC | 83 ms | 12936 KiB |
057.txt | AC | 52 ms | 13432 KiB |
058.txt | AC | 79 ms | 13152 KiB |
059.txt | AC | 53 ms | 13740 KiB |
060.txt | AC | 79 ms | 13064 KiB |
061.txt | AC | 49 ms | 13128 KiB |
062.txt | AC | 80 ms | 13012 KiB |
example0.txt | AC | 12 ms | 9468 KiB |
example1.txt | AC | 12 ms | 9384 KiB |
example2.txt | AC | 12 ms | 9408 KiB |
example3.txt | AC | 12 ms | 9448 KiB |