結果

問題 No.2716 Falcon Method
ユーザー nikoro256nikoro256
提出日時 2024-04-05 22:32:39
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 525 ms / 2,000 ms
コード長 815 bytes
コンパイル時間 416 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 85,780 KB
最終ジャッジ日時 2024-04-05 22:32:49
合計ジャッジ時間 9,491 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,460 KB
testcase_01 AC 35 ms
53,460 KB
testcase_02 AC 37 ms
53,460 KB
testcase_03 AC 37 ms
53,460 KB
testcase_04 AC 37 ms
53,460 KB
testcase_05 AC 37 ms
53,460 KB
testcase_06 AC 70 ms
68,380 KB
testcase_07 AC 73 ms
72,660 KB
testcase_08 AC 71 ms
70,568 KB
testcase_09 AC 71 ms
70,568 KB
testcase_10 AC 65 ms
68,380 KB
testcase_11 AC 352 ms
85,280 KB
testcase_12 AC 395 ms
84,776 KB
testcase_13 AC 356 ms
84,928 KB
testcase_14 AC 448 ms
83,284 KB
testcase_15 AC 371 ms
84,452 KB
testcase_16 AC 420 ms
83,316 KB
testcase_17 AC 462 ms
83,676 KB
testcase_18 AC 525 ms
84,060 KB
testcase_19 AC 406 ms
83,152 KB
testcase_20 AC 355 ms
84,328 KB
testcase_21 AC 344 ms
83,904 KB
testcase_22 AC 392 ms
85,780 KB
testcase_23 AC 510 ms
85,264 KB
testcase_24 AC 415 ms
85,652 KB
testcase_25 AC 38 ms
53,460 KB
testcase_26 AC 37 ms
53,460 KB
testcase_27 AC 489 ms
85,252 KB
testcase_28 AC 520 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)
    if rs[-1]!=0:
        r=solve(rs,rss[P-1]+W)
    else:
        r=10**20
    if ls[-1]!=0:
        l=solve(ls,lss[P-1]+H)
    else:
        l=10**20
    #print(r,l)
    if r>l:
        print(l%N)
    else:
        print(r%N)
0