結果
問題 | No.2716 Falcon Method |
ユーザー |
|
提出日時 | 2024-04-05 21:59:02 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 437 ms / 2,000 ms |
コード長 | 998 bytes |
コンパイル時間 | 455 ms |
コンパイル使用メモリ | 82,360 KB |
実行使用メモリ | 205,824 KB |
最終ジャッジ日時 | 2024-10-01 02:15:39 |
合計ジャッジ時間 | 10,022 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
import collections,sys,math,functools,operator,itertools,bisect,heapq,decimal,string,time,random input = sys.stdin.readline #sys.setrecursionlimit(10**9) #sys.set_int_max_str_digits(0) #input = sys.stdin.readline n,q = map(int,input().split()) s = list(input().rstrip()) d = s.count('D') r = s.count('R') dd = [] rr = [] for i in range(n): dd.append(1 if s[i] == 'D' else 0) rr.append(1 if s[i] == 'R' else 0) for i in range(n): dd.append(1 if s[i] == 'D' else 0) rr.append(1 if s[i] == 'R' else 0) dd = list(itertools.accumulate(dd)) rr = list(itertools.accumulate(rr)) for i in range(q): h,w,p = map(int,input().split()) z = min(h//d if d != 0 else 10**18,w//r if r != 0 else 10**18) h = h - d * z w = w - r * z if h == 0 or w == 0: h += d w += r #print(h,w) di = bisect.bisect_left(dd,(dd[p-1] if p != 0 else 0)+h) ri = bisect.bisect_left(rr,(rr[p-1] if p != 0 else 0)+w) #print(di,ri) j = min(di,ri)+1 print((j)%n)