結果

問題 No.230 Splarraay スプラレェーイ
ユーザー eitahoeitaho
提出日時 2015-06-20 00:29:53
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,609 ms / 5,000 ms
コード長 1,605 bytes
コンパイル時間 523 ms
コンパイル使用メモリ 79,440 KB
実行使用メモリ 4,876 KB
最終ジャッジ日時 2023-09-21 10:24:53
合計ジャッジ時間 12,606 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 80 ms
4,376 KB
testcase_07 AC 9 ms
4,376 KB
testcase_08 AC 35 ms
4,380 KB
testcase_09 AC 748 ms
4,376 KB
testcase_10 AC 1,310 ms
4,876 KB
testcase_11 AC 339 ms
4,380 KB
testcase_12 AC 745 ms
4,376 KB
testcase_13 AC 107 ms
4,380 KB
testcase_14 AC 1,609 ms
4,680 KB
testcase_15 AC 1,441 ms
4,680 KB
testcase_16 AC 1,385 ms
4,756 KB
testcase_17 AC 1,466 ms
4,760 KB
testcase_18 AC 1,187 ms
4,816 KB
testcase_19 AC 598 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <climits>
#include <numeric>
#include <functional>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (int)a; i <= (int)b; i++)
template<class T> void checkmin(T &a, T b) { if (b < a) a = b; }
template<class T> void checkmax(T &a, T b) { if (b > a) a = b; }

const int MaxN = 100000, MaxQ = 100000;
int N, Q;
int X[MaxQ], A[MaxQ], B[MaxQ];

void solve() {
    ll scoreA = 0, scoreB = 0;
    bitset<MaxN> a, b, c;

    rep(i, Q) {
        c.reset();
        c.flip();
        int len = B[i] - A[i] + 1;
        c >>= (MaxN - len);
        c <<= A[i];

        if (X[i] == 0) {
            int countA = (a & c).count(), countB = (b & c).count();
            if (countA > countB) scoreA += countA;
            if (countB > countA) scoreB += countB;
        } else if (X[i] == 1) {
            a |= c;
            c.flip();
            b &= c;
        } else if (X[i] == 2) {
            b |= c;
            c.flip();
            a &= c;
        }
    }

    scoreA += a.count();
    scoreB += b.count();
    printf("%lld %lld\n", scoreA, scoreB);
}

int main() {
    scanf("%d", &N);
    scanf("%d", &Q);
    rep(i, Q) scanf("%d%d%d", &X[i], &A[i], &B[i]);
    solve();
    return 0;
}
0