結果
| 問題 |
No.2716 Falcon Method
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-04-05 22:03:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 640 ms / 2,000 ms |
| コード長 | 730 bytes |
| コンパイル時間 | 235 ms |
| コンパイル使用メモリ | 82,048 KB |
| 実行使用メモリ | 104,192 KB |
| 最終ジャッジ日時 | 2024-10-01 02:19:23 |
| 合計ジャッジ時間 | 10,861 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 28 |
ソースコード
n,Q=map(int,input().split())
s=input()
R=[0]
D=[0]
for i in s:
if i=="R":
R.append(R[-1]+1)
D.append(D[-1])
else:
D.append(D[-1]+1)
R.append(R[-1])
def Rco(start,dist):
g=start+dist
syu=g//n
div=g%n
return R[-1]*syu+R[div]-R[start]
def Dco(start,dist):
g=start+dist
syu=g//n
div=g%n
return D[-1]*syu+D[div]-D[start]
for i in range(Q):
d,r,p=map(int,input().split())
ans=0
for bs in reversed(range(40)):
ans+=2**bs
#print(Dco(p,ans),Rco(p,ans))
if Dco(p,ans)>=d or Rco(p,ans)>=r:
ans-=2**bs
print((p+ans+1)%n)
"""
for i in range(5):
for j in range(5):
print(Rco(i,j))
print("#")
"""