結果

問題 No.2716 Falcon Method
ユーザー planesplanes
提出日時 2024-04-05 22:17:11
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,337 bytes
コンパイル時間 1,631 ms
コンパイル使用メモリ 170,336 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-04-05 22:17:21
合計ジャッジ時間 6,423 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 3 ms
6,676 KB
testcase_07 AC 3 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 3 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 232 ms
6,676 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 195 ms
6,676 KB
testcase_22 AC 236 ms
6,784 KB
testcase_23 WA -
testcase_24 AC 228 ms
6,784 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 WA -
testcase_28 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

 #include <bits/stdc++.h> 
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 #define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

ll INF=2e18;


int main() {
    ios::sync_with_stdio(false);
  cin.tie(0);
  
ll N,Q;cin>>N>>Q;
string S;cin>>S;

vector<ll> x(N+1),y(N+1);

for(ll i=0;i<N;i++) {
  x[i+1]=x[i];
  y[i+1]=y[i];
  if(S[i]=='D') x[i+1]++;
  else y[i+1]++;
}






for(ll i=0;i<Q;i++) {
  ll H,W,P;cin>>H>>W>>P;

  //何回の移動?

  ll s=0;
  ll g=1000000000;

  while(s<g) {
    ll X=0,Y=0;

    //<=の最小

    ll k=(s+g)/2;
    ll K=k;


    ll noko=N-P;

    if(noko<=k) {
      X+=x[N]-x[P];
      Y+=y[N]-y[P];
      k-=N-P;
    }
    else {
      X+=x[P+k]-x[P];
      Y+=y[P+k]-y[P];
      k=0;
    }
    
    ll count=k/N;
    k%=N;
    X+=x[N]*count;
    Y+=y[N]*count;

    if(k>0) {
      X+=x[k];
      Y+=y[k];
    k=0;
    }
  
  if(X>=H||Y>=W) {
    g=K;
  }

  else s=K+1;
  }


  ll k=s;
  ll noko=N-P;
  ll X=0,Y=0;



  if(noko<=k) {
      X+=x[N]-x[P];
      Y+=y[N]-y[P];
      k-=N-P;
    }

    else {
      X+=x[P+k]-x[P];
      Y+=y[P+k]-y[P];
      k=0;
    }
    
    ll count=k/N;
    k%=N;
    X+=x[N]*count;
    Y+=y[N]*count;

    if(k>0) {
      X+=x[k];
      Y+=y[k];
    k=0;
    }

    


  

    cout<<(P+s)%N<<endl;
}


}


0