結果
問題 |
No.2716 Falcon Method
|
ユーザー |
|
提出日時 | 2024-04-05 22:16:09 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 893 bytes |
コンパイル時間 | 2,173 ms |
コンパイル使用メモリ | 196,196 KB |
最終ジャッジ日時 | 2025-02-20 21:30:36 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 22 WA * 6 |
ソースコード
#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/D[N]*N+ll(lower_bound(D.begin(),D.end(),H%D[N])-D.begin()); ll cntW=W/R[N]*N+ll(lower_bound(R.begin(),R.end(),W%R[N])-R.begin()); if(cntH<cntW){ cout<<cntH%N<<'\n'; }else{ cout<<cntW%N<<'\n'; } } } }