結果

問題 No.2045 Two Reflections
ユーザー とりゐとりゐ
提出日時 2022-08-20 00:37:38
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,338 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 78,080 KB
最終ジャッジ日時 2024-04-17 03:03:58
合計ジャッジ時間 3,719 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
54,400 KB
testcase_01 AC 44 ms
53,888 KB
testcase_02 AC 91 ms
77,312 KB
testcase_03 AC 93 ms
77,056 KB
testcase_04 AC 100 ms
77,440 KB
testcase_05 AC 83 ms
76,800 KB
testcase_06 AC 71 ms
70,400 KB
testcase_07 AC 102 ms
76,800 KB
testcase_08 AC 123 ms
78,080 KB
testcase_09 AC 84 ms
75,392 KB
testcase_10 AC 82 ms
75,136 KB
testcase_11 AC 104 ms
77,172 KB
testcase_12 AC 44 ms
54,272 KB
testcase_13 AC 42 ms
53,888 KB
testcase_14 AC 42 ms
54,400 KB
testcase_15 AC 41 ms
53,760 KB
testcase_16 AC 42 ms
53,888 KB
testcase_17 AC 41 ms
53,888 KB
testcase_18 AC 42 ms
54,272 KB
testcase_19 AC 42 ms
54,144 KB
testcase_20 WA -
testcase_21 AC 96 ms
77,056 KB
testcase_22 AC 93 ms
77,056 KB
testcase_23 AC 103 ms
77,056 KB
testcase_24 AC 102 ms
77,184 KB
testcase_25 AC 94 ms
77,056 KB
testcase_26 AC 93 ms
77,184 KB
testcase_27 AC 93 ms
77,056 KB
testcase_28 AC 98 ms
77,184 KB
testcase_29 AC 95 ms
77,184 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from collections import defaultdict
from math import gcd

class UnionFind():
  def __init__(self,n):
    self.n=n
    self.parents=[-1]*n

  def find(self,x):
    if self.parents[x]<0:
      return x
    else:
      self.parents[x]=self.find(self.parents[x])
      return self.parents[x]

  def union(self,x,y):
    x=self.find(x)
    y=self.find(y)

    if x==y:
      return

    if self.parents[x]>self.parents[y]:
      x,y=y,x

    self.parents[x]+=self.parents[y]
    self.parents[y]=x

  def size(self,x):
    return -self.parents[self.find(x)]

  def same(self,x,y):
    return self.find(x)==self.find(y)

  def members(self,x):
    root=self.find(x)
    return [i for i in range(self.n) if self.find(i)==root]

  def roots(self):
    return [i for i, x in enumerate(self.parents) if x< 0]

  def group_count(self):
    return len(self.roots())

  def all_group_members(self):
    group_members=defaultdict(list)
    for member in range(self.n):
      group_members[self.find(member)].append(member)
    return group_members

n,p,q=map(int,input().split())
p,q=min(p,q),max(p,q)
if p==q==1:
  print(1)
  exit()
if p==1:
  print(2)
  exit()

uf=UnionFind(n)
for i in range(p):
  uf.union(i,p-1-i)
for i in range(q):
  uf.union(n-q+i,n-1-i)

lcm=1
for i in range(n):
  lcm=lcm*uf.size(i)//gcd(lcm,uf.size(i))

print(lcm*2%998244353)
0