結果

問題 No.2716 Falcon Method
ユーザー anonymouslyanonymously
提出日時 2024-04-05 23:16:13
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 799 bytes
コンパイル時間 637 ms
コンパイル使用メモリ 11,904 KB
実行使用メモリ 28,272 KB
最終ジャッジ日時 2024-04-05 23:16:26
合計ジャッジ時間 13,007 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 30 ms
10,112 KB
testcase_01 RE -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 RE -
testcase_06 RE -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 RE -
testcase_11 RE -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 RE -
testcase_22 RE -
testcase_23 WA -
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n,q=map(int,input().split())
S=input()
D=[1 if S[0]=='D' else 0]
d=[0] if S[0]=='D' else []
R=[1 if S[0]=='R' else 0]
r=[0] if S[0]=='R' else []
for i in range(1,n):
    if S[i]=='D':
        D.append(D[-1]+1)
        R.append(R[-1])
        d.append(i)
    elif S[i]=='R':
        D.append(D[-1])
        R.append(R[-1]+1)
        r.append(i)

for i in range(q):
    h,w,p=map(int,input().split())
    cycle=min(h//len(d),w//len(r))
    y=h-len(d)*cycle
    x=w-len(r)*cycle
    residue=0
    if y<len(d) and x<len(r):
        residue=min(d[(y+D[p])%len(d)]-D[p],r[(x+R[p])%len(r)]-R[p])
    elif y<len(d) and x>=len(r):
        residue=d[(y+D[p])%len(d)]-D[p]
    elif y>=len(d) and x<len(r):
        residue=r[(x+R[p])%len(r)]-R[p]
    else:
        raise Exception

    print((p+residue)%n)
    
0