結果
問題 | No.2045 Two Reflections |
ユーザー | Shirotsume |
提出日時 | 2022-05-17 14:27:15 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,467 bytes |
コンパイル時間 | 335 ms |
コンパイル使用メモリ | 82,816 KB |
実行使用メモリ | 97,152 KB |
最終ジャッジ日時 | 2024-09-20 03:07:22 |
合計ジャッジ時間 | 3,686 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,608 KB |
testcase_01 | AC | 39 ms
52,480 KB |
testcase_02 | AC | 89 ms
84,736 KB |
testcase_03 | AC | 109 ms
83,940 KB |
testcase_04 | AC | 115 ms
80,956 KB |
testcase_05 | AC | 97 ms
78,168 KB |
testcase_06 | AC | 98 ms
80,748 KB |
testcase_07 | AC | 113 ms
80,616 KB |
testcase_08 | AC | 125 ms
81,316 KB |
testcase_09 | AC | 112 ms
86,084 KB |
testcase_10 | AC | 106 ms
84,052 KB |
testcase_11 | AC | 105 ms
76,984 KB |
testcase_12 | AC | 40 ms
52,224 KB |
testcase_13 | AC | 39 ms
52,480 KB |
testcase_14 | AC | 39 ms
52,352 KB |
testcase_15 | AC | 40 ms
52,608 KB |
testcase_16 | AC | 40 ms
52,224 KB |
testcase_17 | AC | 97 ms
97,024 KB |
testcase_18 | AC | 110 ms
89,964 KB |
testcase_19 | AC | 109 ms
89,804 KB |
testcase_20 | AC | 103 ms
97,152 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
ソースコード
class dsu(): n=1 parent_or_size=[-1 for i in range(n)] def __init__(self,N): self.n=N self.num = N self.parent_or_size=[-1 for i in range(N)] def merge(self,a,b): assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n) assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n) x=self.leader(a) y=self.leader(b) if x==y: return x self.num -= 1 if (-self.parent_or_size[x]<-self.parent_or_size[y]): x,y=y,x self.parent_or_size[x]+=self.parent_or_size[y] self.parent_or_size[y]=x return x def same(self,a,b): assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n) assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n) return self.leader(a)==self.leader(b) def leader(self,a): assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n) if (self.parent_or_size[a]<0): return a self.parent_or_size[a]=self.leader(self.parent_or_size[a]) return self.parent_or_size[a] def size(self,a): assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n) return -self.parent_or_size[self.leader(a)] def groups(self): leader_buf=[0 for i in range(self.n)] group_size=[0 for i in range(self.n)] for i in range(self.n): leader_buf[i]=self.leader(i) group_size[leader_buf[i]]+=1 result=[[] for i in range(self.n)] for i in range(self.n): result[leader_buf[i]].append(i) result2=[] for i in range(self.n): if len(result[i])>0: result2.append(result[i]) return result2 def count(self): return self.num n, p, q = map(int,input().split()) mod = 998244353 a = list(range(0, n)) for i in range(p // 2): a[i], a[p - i - 1] = a[p - i - 1], a[i] for i in range(q // 2): a[n - q + i], a[n - i - 1] = a[n - i - 1], a[n - q + i] U = dsu(n) for i in range(n): U.merge(i, a[i]) count = [0] * (n + 1) for v in U.groups(): x = len(v) for i in range(2, 10 ** 5 + 1): if x == 1: break cnt = 0 while x % i == 0: x //= i cnt += 1 count[i] = max(cnt, count[i]) ans = 1 for i in range(1, n + 1): if count[i] >= 1: ans *= i * count[i] ans %= mod if p > 1 and q > 1: ans *= 2 ans %= mod print(ans)