結果

問題 No.2716 Falcon Method
ユーザー nikoro256nikoro256
提出日時 2024-04-05 22:29:53
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 717 bytes
コンパイル時間 269 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 85,264 KB
最終ジャッジ日時 2024-04-05 22:30:03
合計ジャッジ時間 8,386 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,460 KB
testcase_01 RE -
testcase_02 AC 39 ms
53,460 KB
testcase_03 AC 39 ms
53,460 KB
testcase_04 AC 38 ms
53,460 KB
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 74 ms
72,660 KB
testcase_08 AC 76 ms
70,580 KB
testcase_09 AC 71 ms
70,568 KB
testcase_10 RE -
testcase_11 RE -
testcase_12 AC 412 ms
84,776 KB
testcase_13 AC 383 ms
84,928 KB
testcase_14 AC 493 ms
83,284 KB
testcase_15 AC 376 ms
84,452 KB
testcase_16 AC 452 ms
83,316 KB
testcase_17 AC 469 ms
83,676 KB
testcase_18 AC 521 ms
84,060 KB
testcase_19 AC 445 ms
83,152 KB
testcase_20 AC 362 ms
84,328 KB
testcase_21 RE -
testcase_22 RE -
testcase_23 AC 556 ms
85,264 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 AC 512 ms
85,252 KB
testcase_28 AC 531 ms
85,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N,Q=map(int,input().split())
S=input()
rs=[0 for _ in range(N)]
ls=[0 for _ in range(N)]
for i in range(N):
    if S[i]=='R':
        rs[i]+=1
    else:
        ls[i]+=1
    if i!=0:
        rs[i]+=rs[i-1]
        ls[i]+=ls[i-1]

import bisect
def solve(dat,n):
    if n%dat[-1]==0:
        return n//dat[-1]*N-N+(bisect.bisect_left(dat,dat[-1]))+1
    re=0
    re+=n//dat[-1]*N
    #print('!',dat,n,re)
    re+=bisect.bisect_left(dat,n%dat[i])+1
    return re

rss=rs+[0]
lss=ls+[0]
#print(rss,lss)
for _ in range(Q):
    H,W,P=map(int,input().split())
    #print(rss[P-1]+W,lss[P-1]+H)
    r=solve(rs,rss[P-1]+W)
    l=solve(ls,lss[P-1]+H)
    #print(r,l)
    if r>l:
        print(l%N)
    else:
        print(r%N)
0