結果

問題 No.2983 Christmas Color Grid (Advent Calender ver.)
ユーザー 👑 p-adicp-adic
提出日時 2024-11-21 09:23:36
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 40 ms / 3,340 ms
コード長 4,190 bytes
コンパイル時間 139 ms
コンパイル使用メモリ 13,568 KB
実行使用メモリ 11,648 KB
最終ジャッジ日時 2024-11-21 09:23:40
合計ジャッジ時間 4,650 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 35 ms
11,520 KB
testcase_01 AC 35 ms
11,648 KB
testcase_02 AC 40 ms
11,520 KB
testcase_03 AC 34 ms
11,392 KB
testcase_04 AC 35 ms
11,648 KB
testcase_05 AC 34 ms
11,392 KB
testcase_06 AC 37 ms
11,520 KB
testcase_07 AC 35 ms
11,520 KB
testcase_08 AC 36 ms
11,520 KB
testcase_09 AC 34 ms
11,392 KB
testcase_10 AC 34 ms
11,648 KB
testcase_11 AC 35 ms
11,648 KB
testcase_12 AC 33 ms
11,648 KB
testcase_13 AC 34 ms
11,648 KB
testcase_14 AC 34 ms
11,520 KB
testcase_15 AC 33 ms
11,392 KB
testcase_16 AC 35 ms
11,520 KB
testcase_17 AC 34 ms
11,648 KB
testcase_18 AC 35 ms
11,392 KB
testcase_19 AC 34 ms
11,520 KB
testcase_20 AC 35 ms
11,520 KB
testcase_21 AC 35 ms
11,392 KB
testcase_22 AC 34 ms
11,648 KB
testcase_23 AC 34 ms
11,520 KB
testcase_24 AC 35 ms
11,392 KB
testcase_25 AC 34 ms
11,520 KB
testcase_26 AC 35 ms
11,648 KB
testcase_27 AC 34 ms
11,392 KB
testcase_28 AC 34 ms
11,392 KB
testcase_29 AC 34 ms
11,648 KB
testcase_30 AC 34 ms
11,392 KB
testcase_31 AC 34 ms
11,648 KB
testcase_32 AC 35 ms
11,648 KB
testcase_33 AC 33 ms
11,392 KB
testcase_34 AC 33 ms
11,520 KB
testcase_35 AC 34 ms
11,520 KB
testcase_36 AC 33 ms
11,648 KB
testcase_37 AC 33 ms
11,648 KB
testcase_38 AC 33 ms
11,392 KB
testcase_39 AC 34 ms
11,392 KB
testcase_40 AC 34 ms
11,392 KB
testcase_41 AC 33 ms
11,392 KB
testcase_42 AC 35 ms
11,648 KB
testcase_43 AC 33 ms
11,520 KB
testcase_44 AC 35 ms
11,520 KB
testcase_45 AC 35 ms
11,648 KB
testcase_46 AC 35 ms
11,520 KB
testcase_47 AC 35 ms
11,648 KB
testcase_48 AC 35 ms
11,520 KB
testcase_49 AC 34 ms
11,520 KB
testcase_50 AC 35 ms
11,520 KB
testcase_51 AC 34 ms
11,392 KB
testcase_52 AC 34 ms
11,520 KB
testcase_53 AC 34 ms
11,648 KB
testcase_54 AC 36 ms
11,648 KB
testcase_55 AC 36 ms
11,392 KB
testcase_56 AC 35 ms
11,520 KB
testcase_57 AC 34 ms
11,648 KB
testcase_58 AC 35 ms
11,520 KB
testcase_59 AC 34 ms
11,648 KB
testcase_60 AC 34 ms
11,520 KB
testcase_61 AC 36 ms
11,520 KB
testcase_62 AC 34 ms
11,648 KB
testcase_63 AC 34 ms
11,520 KB
testcase_64 AC 34 ms
11,648 KB
testcase_65 AC 34 ms
11,392 KB
testcase_66 AC 34 ms
11,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

R=range
count=[[0]*26 for i in R(6)]
count[1][1]=[0,1]
count[1][2]=[0,2,1]
count[1][3]=[0,5,2,1]
count[1][4]=[0,12,5,2,1]
count[1][5]=[0,28,12,5,2,1]
count[1][6]=[0,64,28,12,5,2,1]
count[1][7]=[0,144,64,28,12,5,2,1]
count[1][8]=[0,320,144,64,28,12,5,2,1]
count[1][9]=[0,704,320,144,64,28,12,5,2,1]
count[1][10]=[0,1536,704,320,144,64,28,12,5,2,1]
count[1][11]=[0,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][12]=[0,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][13]=[0,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][14]=[0,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][15]=[0,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][16]=[0,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][17]=[0,311296,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][18]=[0,655360,311296,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][19]=[0,1376256,655360,311296,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][20]=[0,2883584,1376256,655360,311296,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][21]=[0,6029312,2883584,1376256,655360,311296,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][22]=[0,12582912,6029312,2883584,1376256,655360,311296,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][23]=[0,26214400,12582912,6029312,2883584,1376256,655360,311296,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][24]=[0,54525952,26214400,12582912,6029312,2883584,1376256,655360,311296,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[1][25]=[0,113246208,54525952,26214400,12582912,6029312,2883584,1376256,655360,311296,147456,69632,32768,15360,7168,3328,1536,704,320,144,64,28,12,5,2,1]
count[2][2]=[0,8,4,4,1]
count[2][3]=[0,40,17,14,10,6,1]
count[2][4]=[0,192,80,64,39,28,20,8,1]
count[2][5]=[0,896,368,296,184,120,81,58,34,10,1]
count[2][6]=[0,4096,1664,1344,856,560,368,240,167,112,52,12,1]
count[2][7]=[0,18432,7424,6016,3904,2568,1712,1112,728,488,337,198,74,14,1]
count[2][8]=[0,81920,32768,26624,17536,11584,7816,5136,3384,2208,1456,992,647,324,100,16,1]
count[2][9]=[0,360448,143360,116736,77824,51584,35136,23304,15520,10232,6704,4392,2936,1976,1169,498,130,18,1]
count[2][10]=[0,1572864,622592,507904,342016,227328,156032,104256,70024,46640,30888,20320,13304,8784,5904,3792,1991,728,164,20,1]
count[2][11]=[0,6815744,2686976,2195456,1490944,993280,686080,461184,311872,209416,139968,93048,61440,40328,26480,17624,11672,6952,3217,1022,202,22,1]
count[2][12]=[0,29360128,11534336,9437184,6455296,4308992,2992128,2021376,1374592,929088,625544,419408,279656,185376,122088,80112,52888,35200,22416,12160,4967,1388,244,24,1]
count[3][3]=[0,400,144,106,84,69,52,32,9,1]
count[3][4]=[0,3840,1360,952,705,550,445,360,270,164,62,12,1]
count[3][5]=[0,35840,12544,8720,6408,4897,3772,2972,2371,1873,1385,854,376,101,15,1]
count[3][6]=[0,327680,113664,78592,57936,44456,34161,26334,20329,15846,12510,9758,7131,4478,2164,714,149,18,1]
count[3][7]=[0,2949120,1015808,699392,516864,398928,308296,238385,183352,140476,108244,84130,65926,50898,36946,23558,12123,4602,1205,206,21,1]
count[3][8]=[0,26214400,8978432,6160384,4561920,3537664,2748496,2136040,1652625,1269794,973997,746362,574842,446028,347449,266040,192322,124150,66909,28072,8654,1876,272,24,1]
count[4][4]=[0,73728,25600,17152,11728,9040,7504,6288,5340,4436,3432,2360,1296,492,116,16,1]
count[4][5]=[0,1376256,471040,314368,213248,158976,128272,105936,89480,75998,64363,53486,42473,31078,19942,10358,3972,1054,186,20,1]
count[4][6]=[0,25165824,8519680,5668864,3856384,2863104,2288896,1868032,1553240,1299184,1090650,919360,774295,643000,517972,394544,274893,167464,83894,32492,9316,1920,272,24,1]
count[5][5]=[0,51380224,17301504,11501568,7749632,5599232,4361216,3564416,3023760,2603088,2265120,1971974,1703398,1448460,1194986,939036,687581,454452,258314,119182,42437,11295,2192,296,25,1]
H,W,K,M=map(int,input().split())
if H>W:H,W=W,H
HW=H*W
print(sum(pow(c,K,M)*count[H][W][c]for c in R(1,HW+1))*sum(pow(HW-n+1,-1,M)for n in R(1,HW+1))*pow(2,-HW,M)%M)
0