結果

問題 No.230 Splarraay スプラレェーイ
ユーザー maine_honzukimaine_honzuki
提出日時 2021-03-03 22:52:21
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,704 ms / 5,000 ms
コード長 858 bytes
コンパイル時間 2,224 ms
コンパイル使用メモリ 197,844 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-14 14:44:47
合計ジャッジ時間 13,559 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,816 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 8 ms
6,944 KB
testcase_06 AC 72 ms
6,944 KB
testcase_07 AC 9 ms
6,940 KB
testcase_08 AC 32 ms
6,944 KB
testcase_09 AC 666 ms
6,944 KB
testcase_10 AC 1,149 ms
6,944 KB
testcase_11 AC 301 ms
6,940 KB
testcase_12 AC 665 ms
6,940 KB
testcase_13 AC 95 ms
6,940 KB
testcase_14 AC 1,704 ms
6,944 KB
testcase_15 AC 1,372 ms
6,944 KB
testcase_16 AC 1,296 ms
6,940 KB
testcase_17 AC 1,303 ms
6,940 KB
testcase_18 AC 1,207 ms
6,940 KB
testcase_19 AC 527 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main() {
    int N, Q;
    cin >> N >> Q;
    const int LEN = 100010;
    bitset<LEN> B[2], mask;
    long long ans[2] = {};
    while (Q--) {
        int x, l, r;
        cin >> x >> l >> r;
        r++;
        mask.reset();
        mask.flip();
        mask >>= LEN - (r - l);
        mask <<= l;
        if (x == 0) {
            int cnt[2];
            cnt[0] = (mask & B[0]).count();
            cnt[1] = (mask & B[1]).count();
            if (cnt[0] > cnt[1])
                ans[0] += cnt[0];
            else if (cnt[1] > cnt[0])
                ans[1] += cnt[1];
        } else {
            x--;
            B[x] |= mask;
            mask.flip();
            B[1 - x] &= mask;
        }
    }
    ans[0] += B[0].count();
    ans[1] += B[1].count();
    cout << ans[0] << " " << ans[1] << endl;
}
0