結果
問題 | No.2983 Christmas Color Grid (Advent Calender ver.) |
ユーザー |
![]() |
提出日時 | 2024-12-09 18:30:18 |
言語 | PyPy3 (7.3.15) |
結果 |
MLE
|
実行時間 | - |
コード長 | 1,651 bytes |
コンパイル時間 | 367 ms |
コンパイル使用メモリ | 82,460 KB |
実行使用メモリ | 163,492 KB |
最終ジャッジ日時 | 2024-12-09 18:32:20 |
合計ジャッジ時間 | 120,795 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 TLE * 1 MLE * 1 |
other | AC * 35 TLE * 20 MLE * 9 |
ソースコード
import sys# sys.setrecursionlimit(200005)# sys.set_int_max_str_digits(200005)int1 = lambda x: int(x)-1pDB = lambda *x: print(*x, end="\n", file=sys.stderr)p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr)def II(): return int(sys.stdin.readline())def LI(): return list(map(int, sys.stdin.readline().split()))def LLI(rows_number): return [LI() for _ in range(rows_number)]def LI1(): return list(map(int1, sys.stdin.readline().split()))def LLI1(rows_number): return [LI1() for _ in range(rows_number)]def SI(): return sys.stdin.readline().rstrip()dij = [(0, 1), (-1, 0), (0, -1), (1, 0)]# dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)]# inf = -1-(-1 << 31)inf = -1-(-1 << 62)# md = 10**9+7# md = 998244353def cal(a):def dfs(ij):def push(ij):if a[ij]==0:returna[ij]=0st.append(ij)cnt=0st=[ij]a[ij]=0while st:ij=st.pop()cnt+=1i,j=divmod(ij,w)if i+1<h:push(ij+w)if j+1<w:push(ij+1)if i:push(ij-w)if j:push(ij-1)return val[cnt]res=0for i in range(h):for j in range(w):ij=i*w+jif a[ij]==0:continueres+=dfs(ij)return resh,w,k,md=LI()n=h*wval=[pow(i,k,md) for i in range(n+1)]st=[[]]s=0while st:a=st.pop()if len(a)==n:s+=cal(a)s%=mdelse:st.append(a+[0])st.append(a+[1])coe=0for i in range(n):coe+=pow(i+1,md-2,md)coe%=mdans=s*coe%md*pow(2,n*(md-2),md)%mdprint(ans)