結果
問題 | No.2045 Two Reflections |
ユーザー | Shirotsume |
提出日時 | 2022-05-17 14:29:06 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 123 ms / 2,000 ms |
コード長 | 2,470 bytes |
コンパイル時間 | 148 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 97,280 KB |
最終ジャッジ日時 | 2024-09-20 03:07:26 |
合計ジャッジ時間 | 3,570 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
52,608 KB |
testcase_01 | AC | 41 ms
52,608 KB |
testcase_02 | AC | 90 ms
84,608 KB |
testcase_03 | AC | 110 ms
84,072 KB |
testcase_04 | AC | 110 ms
81,080 KB |
testcase_05 | AC | 94 ms
78,300 KB |
testcase_06 | AC | 96 ms
80,496 KB |
testcase_07 | AC | 109 ms
80,744 KB |
testcase_08 | AC | 123 ms
81,452 KB |
testcase_09 | AC | 107 ms
86,076 KB |
testcase_10 | AC | 103 ms
84,052 KB |
testcase_11 | AC | 105 ms
77,500 KB |
testcase_12 | AC | 38 ms
52,224 KB |
testcase_13 | AC | 39 ms
52,480 KB |
testcase_14 | AC | 38 ms
52,224 KB |
testcase_15 | AC | 39 ms
52,608 KB |
testcase_16 | AC | 39 ms
52,352 KB |
testcase_17 | AC | 96 ms
97,280 KB |
testcase_18 | AC | 107 ms
89,976 KB |
testcase_19 | AC | 114 ms
90,192 KB |
testcase_20 | AC | 98 ms
97,152 KB |
testcase_21 | AC | 95 ms
84,608 KB |
testcase_22 | AC | 100 ms
84,480 KB |
testcase_23 | AC | 99 ms
84,480 KB |
testcase_24 | AC | 92 ms
84,608 KB |
testcase_25 | AC | 93 ms
84,352 KB |
testcase_26 | AC | 98 ms
87,504 KB |
testcase_27 | AC | 106 ms
87,580 KB |
testcase_28 | AC | 96 ms
87,248 KB |
testcase_29 | AC | 91 ms
84,992 KB |
ソースコード
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 *= pow(i, count[i]) ans %= mod if p > 1 and q > 1: ans *= 2 ans %= mod print(ans)