結果
問題 | No.2716 Falcon Method |
ユーザー |
|
提出日時 | 2024-04-05 22:19:44 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 913 bytes |
コンパイル時間 | 2,181 ms |
コンパイル使用メモリ | 195,888 KB |
最終ジャッジ日時 | 2025-02-20 21:34:54 |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 28 |
ソースコード
#include<bits/stdc++.h> using namespace std; using ll=long long; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int N,Q; cin>>N>>Q; string S; cin>>S; vector R(N+1,0),D(N+1,0); for(int i=0;i<N;i++){ R[i+1]=R[i]; D[i+1]=D[i]; if(S[i]=='R'){ R[i+1]+=1; }else{ D[i+1]+=1; } } if(D[N]==0){ while(Q--){ ll H,W,P; cin>>H>>W>>P; cout<<(W+P)%N<<'\n'; } }else if(R[N]==0){ while(Q--){ ll H,W,P; cin>>H>>W>>P; cout<<(H+P)%N<<'\n'; } }else{ while(Q--){ ll H,W,P; cin>>H>>W>>P; H+=D[P]; W+=R[P]; ll cntH=(H-1)/D[N]*N+ll(lower_bound(D.begin(),D.end(),(H-1)%D[N]+1)-D.begin()); ll cntW=(W-1)/R[N]*N+ll(lower_bound(R.begin(),R.end(),(W-1)%R[N]+1)-R.begin()); if(cntH<cntW){ cout<<cntH%N<<'\n'; }else{ cout<<cntW%N<<'\n'; } } } }