結果

問題 No.2080 Simple Nim Query
ユーザー tokumini_sstokumini_ss
提出日時 2022-09-25 21:53:16
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 457 ms / 3,000 ms
コード長 1,134 bytes
コンパイル時間 2,046 ms
コンパイル使用メモリ 203,988 KB
実行使用メモリ 13,352 KB
最終ジャッジ日時 2023-09-03 02:49:12
合計ジャッジ時間 6,274 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 290 ms
7,748 KB
testcase_04 AC 299 ms
7,924 KB
testcase_05 AC 457 ms
13,220 KB
testcase_06 AC 415 ms
13,316 KB
testcase_07 AC 415 ms
13,276 KB
testcase_08 AC 399 ms
13,272 KB
testcase_09 AC 405 ms
13,272 KB
testcase_10 AC 422 ms
13,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#include <atcoder/segtree.hpp>
int64_t op(int64_t a, int64_t b) { return max(a, b); }
int64_t e() { return -1; }

int main() {
    int64_t N, Q;
    cin >> N >> Q;
    vector<int64_t> A(N);
    for (int64_t& a : A) {
        cin >> a;
    }

    vector<int64_t> T(Q), X(Q), Y(Q);
    for (int64_t i = 0; i < Q; i++) {
        cin >> T[i] >> X[i] >> Y[i];
        X[i]--;
    }

    atcoder::segtree<int64_t, op, e> seg(A);

    for (int64_t i = 0; i < Q; i++) {
        if (T[i] == 1) {
            A[X[i]] = Y[i];
            seg.set(X[i], Y[i]);
        } else {
            if (N == 1) {
                cout << "F" << endl;
            } else {
                const int64_t pre = A[X[i]];
                A[X[i]] = 2;
                seg.set(X[i], 2);
                auto f = [&](int64_t x) { return x < 2; };
                const int64_t index = seg.min_left(Y[i], f);
                const int64_t diff = Y[i] - index;
                cout << (diff % 2 == 0 ? "F" : "S") << endl;
                A[X[i]] = pre;
                seg.set(X[i], pre);
            }
        }
    }
}
0