結果

問題 No.2716 Falcon Method
ユーザー Jeroen Op de BeekJeroen Op de Beek
提出日時 2024-04-05 21:38:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 1,428 bytes
コンパイル時間 2,305 ms
コンパイル使用メモリ 203,672 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-04-05 21:38:17
合計ジャッジ時間 5,617 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 1 ms
6,676 KB
testcase_02 AC 1 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 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 3 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 99 ms
6,676 KB
testcase_12 AC 76 ms
6,676 KB
testcase_13 AC 60 ms
6,676 KB
testcase_14 AC 91 ms
6,676 KB
testcase_15 AC 78 ms
6,676 KB
testcase_16 AC 77 ms
6,676 KB
testcase_17 AC 90 ms
6,676 KB
testcase_18 AC 106 ms
6,676 KB
testcase_19 AC 77 ms
6,676 KB
testcase_20 AC 63 ms
6,676 KB
testcase_21 AC 79 ms
6,676 KB
testcase_22 AC 91 ms
6,676 KB
testcase_23 AC 92 ms
6,676 KB
testcase_24 AC 90 ms
6,676 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 1 ms
6,676 KB
testcase_27 AC 83 ms
6,676 KB
testcase_28 AC 99 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;
#define all(x) x.begin(),x.end()
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << p.first << " " << p.second; }
template<typename T_container, typename T = typename enable_if<!is_same<T_container, string>::value, typename T_container::value_type>::type> ostream& operator<<(ostream &os, const T_container &v) { string sep; for (const T &x : v) os << sep << x, sep = " "; return os; }
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#define ASSERT(...) 42
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pi;
const int oo = 1e9;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,q; cin >> n >> q;
    string s; cin >> s;
    vi prefx(n+1),prefy(n+1);
    for(int i=0;i<n;++i) {
        prefx[i+1]=prefx[i] + (s[i]=='R');
        prefy[i+1]=prefy[i]+(s[i]=='D');
    }
    while(q--) {
        int h,w,p; cin >> h >> w >> p;
        ll lo = 0, hi = 2e9;
        while(lo<hi) {
            auto mid = (lo+hi)/2;
            auto e = (mid+p)%n;
            ll loops = (p+mid)/n - p/n;
            auto get = [&](vi& v) {
                return v[n]*loops + v[e]-v[p];
            };
            if(get(prefx)>=w or get(prefy)>=h) {
                hi = mid;
            } else lo = mid+1;
        }
        cout << (lo+p)%n << '\n';
    }
}
0