Submission #10891808
Source Code Expand
import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines import itertools A,B,C = read().decode().split() A = list(A) B = list(B) C = list(C) def can_match(x,y): return x == '?' or y == '?' or x == y M = 2020 def solve(A,B,C,LA,LB,LC): B_from_A = [True] * (M+1) for i in range(M+1): B_from_A[i] = all(can_match(x,y) for x,y in zip(A[i:],B)) C_from_A = [True] * (M+M+1) for i in range(M+M+1): C_from_A[i] = all(can_match(x,y) for x,y in zip(A[i:],C)) C_from_B = [True] * (M+1) for i in range(M+1): C_from_B[i] = all(can_match(x,y) for x,y in zip(B[i:],C)) for i in range(M): if not B_from_A[i]: continue for j in range(M): if not C_from_B[j]: continue if not C_from_A[i+j]: continue yield max(LA, LB+i, LC+i+j) break answer = 10 ** 9 for A,B,C in itertools.permutations([A,B,C]): LA = len(A) LB = len(B) LC = len(C) x = min(solve(A,B,C,LA,LB,LC)) if answer > x: answer = x print(answer)
Submission Info
Submission Time | |
---|---|
Task | E - Three Substrings |
User | maspy |
Language | PyPy3 (2.4.0) |
Score | 500 |
Code Size | 1190 Byte |
Status | AC |
Exec Time | 1331 ms |
Memory | 90204 KiB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | example0.txt, example1.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, 063.txt, 064.txt, 065.txt, 066.txt, 067.txt, 068.txt, example0.txt, example1.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
000.txt | AC | 227 ms | 44528 KiB |
001.txt | AC | 225 ms | 44144 KiB |
002.txt | AC | 290 ms | 49516 KiB |
003.txt | AC | 942 ms | 81500 KiB |
004.txt | AC | 1331 ms | 83164 KiB |
005.txt | AC | 345 ms | 53868 KiB |
006.txt | AC | 346 ms | 53868 KiB |
007.txt | AC | 338 ms | 53868 KiB |
008.txt | AC | 326 ms | 53868 KiB |
009.txt | AC | 328 ms | 53996 KiB |
010.txt | AC | 333 ms | 53868 KiB |
011.txt | AC | 1049 ms | 89948 KiB |
012.txt | AC | 956 ms | 75380 KiB |
013.txt | AC | 978 ms | 85980 KiB |
014.txt | AC | 792 ms | 78172 KiB |
015.txt | AC | 971 ms | 88412 KiB |
016.txt | AC | 936 ms | 75484 KiB |
017.txt | AC | 890 ms | 75740 KiB |
018.txt | AC | 953 ms | 76764 KiB |
019.txt | AC | 992 ms | 83968 KiB |
020.txt | AC | 953 ms | 77020 KiB |
021.txt | AC | 885 ms | 75612 KiB |
022.txt | AC | 1049 ms | 85980 KiB |
023.txt | AC | 983 ms | 75612 KiB |
024.txt | AC | 1010 ms | 90204 KiB |
025.txt | AC | 924 ms | 87900 KiB |
026.txt | AC | 876 ms | 76668 KiB |
027.txt | AC | 931 ms | 76892 KiB |
028.txt | AC | 909 ms | 78300 KiB |
029.txt | AC | 1109 ms | 77916 KiB |
030.txt | AC | 1050 ms | 86108 KiB |
031.txt | AC | 1088 ms | 76508 KiB |
032.txt | AC | 1134 ms | 88540 KiB |
033.txt | AC | 918 ms | 75212 KiB |
034.txt | AC | 953 ms | 85980 KiB |
035.txt | AC | 1054 ms | 88668 KiB |
036.txt | AC | 975 ms | 76124 KiB |
037.txt | AC | 860 ms | 74204 KiB |
038.txt | AC | 908 ms | 73948 KiB |
039.txt | AC | 1029 ms | 89180 KiB |
040.txt | AC | 916 ms | 74376 KiB |
041.txt | AC | 899 ms | 76508 KiB |
042.txt | AC | 860 ms | 73564 KiB |
043.txt | AC | 943 ms | 77916 KiB |
044.txt | AC | 902 ms | 77788 KiB |
045.txt | AC | 897 ms | 74460 KiB |
046.txt | AC | 979 ms | 74972 KiB |
047.txt | AC | 519 ms | 66908 KiB |
048.txt | AC | 640 ms | 72796 KiB |
049.txt | AC | 539 ms | 70492 KiB |
050.txt | AC | 718 ms | 76636 KiB |
051.txt | AC | 628 ms | 75484 KiB |
052.txt | AC | 678 ms | 85740 KiB |
053.txt | AC | 626 ms | 78684 KiB |
054.txt | AC | 569 ms | 75356 KiB |
055.txt | AC | 529 ms | 73308 KiB |
056.txt | AC | 495 ms | 69596 KiB |
057.txt | AC | 560 ms | 75100 KiB |
058.txt | AC | 542 ms | 74972 KiB |
059.txt | AC | 586 ms | 76508 KiB |
060.txt | AC | 496 ms | 70364 KiB |
061.txt | AC | 602 ms | 82652 KiB |
062.txt | AC | 558 ms | 76252 KiB |
063.txt | AC | 624 ms | 79580 KiB |
064.txt | AC | 587 ms | 80236 KiB |
065.txt | AC | 603 ms | 79324 KiB |
066.txt | AC | 423 ms | 65372 KiB |
067.txt | AC | 1059 ms | 72540 KiB |
068.txt | AC | 1115 ms | 72156 KiB |
example0.txt | AC | 253 ms | 47088 KiB |
example1.txt | AC | 228 ms | 44144 KiB |