結果

問題 No.2716 Falcon Method
ユーザー Nzt3Nzt3
提出日時 2024-04-05 22:19:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 79 ms / 2,000 ms
コード長 913 bytes
コンパイル時間 2,174 ms
コンパイル使用メモリ 204,472 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 22:19:57
合計ジャッジ時間 4,912 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,548 KB
testcase_01 AC 3 ms
6,548 KB
testcase_02 AC 2 ms
6,548 KB
testcase_03 AC 2 ms
6,548 KB
testcase_04 AC 2 ms
6,548 KB
testcase_05 AC 2 ms
6,548 KB
testcase_06 AC 2 ms
6,548 KB
testcase_07 AC 2 ms
6,548 KB
testcase_08 AC 2 ms
6,548 KB
testcase_09 AC 2 ms
6,548 KB
testcase_10 AC 2 ms
6,548 KB
testcase_11 AC 37 ms
6,548 KB
testcase_12 AC 53 ms
6,548 KB
testcase_13 AC 42 ms
6,548 KB
testcase_14 AC 65 ms
6,548 KB
testcase_15 AC 47 ms
6,548 KB
testcase_16 AC 55 ms
6,548 KB
testcase_17 AC 64 ms
6,548 KB
testcase_18 AC 76 ms
6,548 KB
testcase_19 AC 56 ms
6,548 KB
testcase_20 AC 45 ms
6,548 KB
testcase_21 AC 32 ms
6,548 KB
testcase_22 AC 42 ms
6,548 KB
testcase_23 AC 79 ms
6,548 KB
testcase_24 AC 41 ms
6,548 KB
testcase_25 AC 2 ms
6,548 KB
testcase_26 AC 2 ms
6,548 KB
testcase_27 AC 76 ms
6,548 KB
testcase_28 AC 76 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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';
      }
    }
  }
}
0