結果

問題 No.2716 Falcon Method
ユーザー t9unkubjt9unkubj
提出日時 2025-01-15 17:28:33
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
RE  
実行時間 -
コード長 2,032 bytes
コンパイル時間 4,152 ms
コンパイル使用メモリ 296,100 KB
実行使用メモリ 6,824 KB
最終ジャッジ日時 2025-01-15 17:28:43
合計ジャッジ時間 9,787 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18 RE * 10
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#ifdef t9unkubj
#include"debug.cpp"
//#include"template_no_debug.h"
#else
#define dbg(...) 199958
#endif
#undef _GLIBCXX_DEBUG
#pragma GCC optimize("O3")
using namespace std;
#include<bits/stdc++.h>
using ll=long long;
using ull=unsigned long long;
template<class T>using vc=vector<T>;
template<class T>using vvc=vc<vc<T>>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,j,n) for(ll i=(j);i<(ll)(n);i++)
#define DREP(i,n,m) for(ll i=(n);i>=(m);i--)
#define drep(i,n) for(ll i=((n)-1);i>=0;i--)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
template<class T,class F>
bool chmin(T &x, F y){
if(x>y){
x=y;
return true;
}
return false;
}
template<class T, class F>
bool chmax(T &x, F y){
if(x<y){
x=y;
return true;
}
return false;
}
double pass_time=0;
void solve(){
int n,q;
cin>>n>>q;
vc<int>pre1(n+1);
vc<int>pre2(n+1);
rep(i,n){
char c;
cin>>c;
pre1[i+1]=pre1[i]+(c=='D');
pre2[i+1]=pre2[i]+(c=='R');
}
dbg(pre1,pre2);
auto work=[&](int&x,int&y,int h,int w,int&p){
int ac=p,wa=n+1;
while(wa-ac>1){
int wj=ac+wa>>1;
int d1=pre1[wj]-pre1[p];
int d2=pre2[wj]-pre2[p];
if(x+d1>=h||y+d2>=w)wa=wj;
else ac=wj;
}
int d1=pre1[ac]-pre1[p];
int d2=pre2[ac]-pre2[p];
x+=d1,y+=d2;
p=ac;
p%=n;
};
while(q--){
int h,w,p;
cin>>h>>w>>p;
int x=0,y=0;
work(x,y,h,w,p);
if(p){
cout<<(p+1)%n<<"\n";
continue;;
}
int U1=(h-1-x)/pre1[n];
int U2=(w-1-y)/pre2[n];
x+=min(U2,U1)*pre1[n];
y+=min(U2,U1)*pre2[n];
work(x,y,h,w,p);
cout<<(p+1)%n<<"\n";
}
}
signed main(){
cin.tie(0)->sync_with_stdio(0);
pass_time=clock();
int t=1;
//cin>>t;
while(t--)solve();
pass_time=clock()-pass_time;
dbg(pass_time/CLOCKS_PER_SEC);
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0