結果

問題 No.2716 Falcon Method
ユーザー flygonflygon
提出日時 2024-04-05 22:16:52
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,017 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 84,848 KB
最終ジャッジ日時 2024-04-05 22:16:59
合計ジャッジ時間 6,456 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
55,720 KB
testcase_01 AC 47 ms
55,720 KB
testcase_02 AC 45 ms
55,720 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 67 ms
68,308 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
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 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 45 ms
55,720 KB
testcase_26 AC 45 ms
55,720 KB
testcase_27 AC 259 ms
84,452 KB
testcase_28 AC 266 ms
84,452 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
sys.setrecursionlimit(5*10**5)
input = sys.stdin.readline
from collections import defaultdict, deque, Counter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right
from math import gcd

n,q = map(int,input().split())
s = input().rstrip()
s = s+s
d = [0]*(2*n+1)
r = [0]*(2*n+1)
for i in range(2*n):
    if s[i] == "D":
        d[i+1] = 1
    else:
        r[i+1] = 1
    d[i+1] += d[i]
    r[i+1] += r[i]

dnum = d[-1]//2
rnum = d[-1]//2

for i in range(q):
    h,w,p = map(int,input().split())
    p += 1
    dloop = 10**15
    rloop = 10**15
    dt = n
    rt = n
    if dnum != 0:
        dloop = h//dnum
        dleft = d[p-1] + (h%dnum)
        dt = bisect_left(d, dleft)
    if rnum != 0:
        rloop = w//rnum
        rleft = r[p-1] + (w%rnum)
        rt = bisect_left(r, rleft)
    if dt >= n:
        dloop += dt//n
        dt %= n
    if rt >= n:
        rloop += rt//n
        rt %= n
    if [dloop, dt] <= [rloop, rt]:
        print(dt)
    else:
        print(rt)
0