結果

問題 No.2716 Falcon Method
ユーザー flygonflygon
提出日時 2024-04-05 22:19:48
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 317 ms / 2,000 ms
コード長 1,017 bytes
コンパイル時間 583 ms
コンパイル使用メモリ 81,700 KB
実行使用メモリ 84,720 KB
最終ジャッジ日時 2024-04-05 22:20:11
合計ジャッジ時間 6,506 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 44 ms
55,720 KB
testcase_01 AC 47 ms
55,720 KB
testcase_02 AC 45 ms
55,720 KB
testcase_03 AC 43 ms
55,720 KB
testcase_04 AC 44 ms
55,720 KB
testcase_05 AC 43 ms
55,720 KB
testcase_06 AC 63 ms
68,312 KB
testcase_07 AC 65 ms
70,372 KB
testcase_08 AC 70 ms
70,380 KB
testcase_09 AC 67 ms
70,372 KB
testcase_10 AC 64 ms
68,320 KB
testcase_11 AC 186 ms
83,220 KB
testcase_12 AC 268 ms
84,612 KB
testcase_13 AC 232 ms
84,720 KB
testcase_14 AC 296 ms
83,544 KB
testcase_15 AC 244 ms
84,388 KB
testcase_16 AC 285 ms
83,572 KB
testcase_17 AC 302 ms
83,820 KB
testcase_18 AC 317 ms
84,220 KB
testcase_19 AC 258 ms
83,444 KB
testcase_20 AC 254 ms
84,292 KB
testcase_21 AC 183 ms
82,448 KB
testcase_22 AC 198 ms
83,576 KB
testcase_23 AC 306 ms
84,592 KB
testcase_24 AC 201 ms
83,576 KB
testcase_25 AC 44 ms
55,720 KB
testcase_26 AC 44 ms
55,720 KB
testcase_27 AC 249 ms
84,580 KB
testcase_28 AC 259 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 = r[-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