結果
問題 |
No.2716 Falcon Method
|
ユーザー |
|
提出日時 | 2024-04-05 23:16:13 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
RE
|
実行時間 | - |
コード長 | 799 bytes |
コンパイル時間 | 525 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 28,704 KB |
最終ジャッジ日時 | 2024-10-01 03:04:59 |
合計ジャッジ時間 | 13,479 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | WA * 18 RE * 10 |
ソースコード
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)