結果

問題 No.2716 Falcon Method
ユーザー inkyamaninkyaman
提出日時 2024-04-07 00:02:40
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 458 ms / 2,000 ms
コード長 1,116 bytes
コンパイル時間 1,200 ms
コンパイル使用メモリ 118,940 KB
実行使用メモリ 6,784 KB
最終ジャッジ日時 2024-04-07 00:02:50
合計ジャッジ時間 9,564 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 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 5 ms
6,676 KB
testcase_07 AC 5 ms
6,676 KB
testcase_08 AC 5 ms
6,676 KB
testcase_09 AC 4 ms
6,676 KB
testcase_10 AC 4 ms
6,676 KB
testcase_11 AC 414 ms
6,676 KB
testcase_12 AC 299 ms
6,676 KB
testcase_13 AC 248 ms
6,676 KB
testcase_14 AC 372 ms
6,676 KB
testcase_15 AC 262 ms
6,676 KB
testcase_16 AC 312 ms
6,676 KB
testcase_17 AC 386 ms
6,676 KB
testcase_18 AC 436 ms
6,676 KB
testcase_19 AC 318 ms
6,676 KB
testcase_20 AC 267 ms
6,676 KB
testcase_21 AC 341 ms
6,676 KB
testcase_22 AC 440 ms
6,784 KB
testcase_23 AC 458 ms
6,784 KB
testcase_24 AC 442 ms
6,784 KB
testcase_25 AC 2 ms
6,676 KB
testcase_26 AC 2 ms
6,676 KB
testcase_27 AC 451 ms
6,784 KB
testcase_28 AC 456 ms
6,784 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;

int N,Q;
string S;

int main() {

    cin >> N >> Q >> S;
    vector<int> hsum(2*N+1,0), wsum(2*N+1,0);
    for(int i = 0; i < 2*N; ++i) {
        hsum[i+1] = hsum[i];
        wsum[i+1] = wsum[i];
        if(S[i%N] == 'D') hsum[i+1]++;
        else wsum[i+1]++;
    }

    int hcnt = hsum[N];
    int wcnt = wsum[N];

    while(Q--) {
        int H, W, P; cin >> H >> W >> P;
        ll l = 0, r = 1e18;
        while(r-l>1) {
            ll mid = l+(r-l)/2;
            ll hans = mid/N*hcnt;
            ll wans = mid/N*wcnt;
            hans += hsum[(mid%N)+P]-hsum[P];
            wans += wsum[(mid%N)+P]-wsum[P];

            if(hans >= H || wans >= W) r = mid;
            else l = mid;
        }

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

}

0