結果

問題 No.2716 Falcon Method
ユーザー titiatitia
提出日時 2024-04-06 00:11:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 987 bytes
コンパイル時間 233 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 283,964 KB
最終ジャッジ日時 2024-04-06 00:11:46
合計ジャッジ時間 5,406 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

import sys
input = sys.stdin.readline

N,Q=map(int,input().split())
S=input().strip()


for queries in range(Q):
    H,W,P=map(int,input().split())

    D=[0]
    R=[0]
    for s in S:
        D.append(D[-1])
        R.append(R[-1])

        if s=="D":
            D[-1]+=1
        else:
            R[-1]+=1

    # 何歩で下にたどりつくか?

    OK=2*(10**9)+10
    NG=0

    while OK>NG+1:
        mid=(OK+NG)//2

        #print(mid,P,N)

        if mid+P<=N:
            down=D[mid+P]-D[P]
            right=R[mid+P]-R[P]
            #print("!",mid,down,right)
        else:
            down=D[-1]-D[P-1]
            right=R[-1]-R[P-1]

            midx=mid-(N-P)

            kk=midx//N
            rest=midx%N

            down+=kk*D[-1]
            right+=kk*R[-1]

            down+=D[rest]
            right+=R[rest]

        #print(mid,down,right)

        if H<=down or W<=right:
            OK=mid
        else:
            NG=mid
            
    print((OK+P)%N)

0