結果
問題 | No.1885 Flat Permutation |
ユーザー |
|
提出日時 | 2022-03-25 23:14:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,944 bytes |
コンパイル時間 | 218 ms |
コンパイル使用メモリ | 82,048 KB |
実行使用メモリ | 72,960 KB |
最終ジャッジ日時 | 2024-10-14 07:22:25 |
合計ジャッジ時間 | 5,092 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 35 WA * 8 |
ソースコード
# import sys# input = sys.stdin.readline# import pypyjit# pypyjit.set_param('max_unroll_recursion=-1')def mp():return map(int,input().split())def lmp():return list(map(int,input().split()))def mps(A):return [tuple(map(int, input().split())) for _ in range(A)]def stoi(LIST):return list(map(int,LIST))def itos(LIST):return list(map(str,LIST))def bitA(X,A):return X & 1<<A == 1<<Aimport mathimport bisectimport heapqimport timefrom copy import copy as ccfrom copy import deepcopy as dcfrom itertools import accumulate, productfrom collections import Counter, defaultdict, dequedef ceil(U,V):return (U+V-1)//Vdef modf1(N,MOD):return (N-1)%MOD+1inf = int(1e18+20)mod = 998244353n,x,y = mp()if x > y:x,y = y,xif x != 1 and y != n:if y-x == 1:print(0)else:step = y - 1 - (x+1) - 3jump = 1ans = 1now = 1while step >= 0:bunsi = (step+1) * (step+2)* (step+3)% modbunbo = jump * (step+jump+1)*(step+jump+2)% modnow *= bunsi*pow(bunbo,mod-2,mod)now %= modans += nowans %= modstep -= 3jump += 1print(ans % mod)elif x == 1:step = y-1-3jump = 1ans = 1now = 1while step >= 0:bunsi = (step + 1) * (step + 2) * (step + 3)% modbunbo = jump * (step + jump + 1) * (step + jump + 2)% modnow *= bunsi * pow(bunbo, mod - 2, mod)now %= modans += nowans %= modstep -= 3jump += 1print(ans % mod)else:step = n-x-3jump = 1ans = 1now = 1while step >= 0:bunsi = (step + 1) * (step + 2) * (step + 3)% modbunbo = jump * (step + jump + 1) * (step + jump + 2)% modnow *= bunsi * pow(bunbo, mod - 2, mod)now %= modans += nowans %= modstep -= 3jump += 1print(ans % mod)