結果

問題 No.230 Splarraay スプラレェーイ
ユーザー 0w10w1
提出日時 2017-04-27 19:14:13
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,409 ms / 5,000 ms
コード長 855 bytes
コンパイル時間 2,244 ms
コンパイル使用メモリ 168,368 KB
実行使用メモリ 4,356 KB
最終ジャッジ日時 2023-10-11 16:08:17
合計ジャッジ時間 12,742 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 8 ms
4,348 KB
testcase_06 AC 71 ms
4,348 KB
testcase_07 AC 9 ms
4,348 KB
testcase_08 AC 33 ms
4,352 KB
testcase_09 AC 649 ms
4,356 KB
testcase_10 AC 1,153 ms
4,352 KB
testcase_11 AC 298 ms
4,348 KB
testcase_12 AC 647 ms
4,348 KB
testcase_13 AC 95 ms
4,348 KB
testcase_14 AC 1,409 ms
4,352 KB
testcase_15 AC 1,363 ms
4,348 KB
testcase_16 AC 1,275 ms
4,352 KB
testcase_17 AC 1,268 ms
4,348 KB
testcase_18 AC 1,069 ms
4,348 KB
testcase_19 AC 522 ms
4,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int MAXN = int( 1e5 );

int N;
int Q;

signed main() {
  ios::sync_with_stdio( 0 );
  cin >> N;
  cin >> Q;
  bitset< MAXN > team[ 2 ], mask;
  long long ans[ 2 ] = { 0, 0 };
  for( int qi = 0; qi < Q; ++qi ) {
    int x, l, r;
    cin >> x >> l >> r;
    mask.reset();
    mask.flip();
    mask >>= MAXN - ( r - l + 1 );
    mask <<= l;
    if( x == 0 ) {
      int ca = ( mask & team[ 0 ] ).count();
      int cb = ( mask & team[ 1 ] ).count();
      if( ca == cb ) continue;
      if( ca > cb ) {
        ans[ 0 ] += ca;
      } else {
        ans[ 1 ] += cb;
      }
    } else {
      team[ x - 1 ] |= mask;
      mask.flip();
      team[ x - 1 ^ 1 ] &= mask;
    }
  }
  ans[ 0 ] += team[ 0 ].count();
  ans[ 1 ] += team[ 1 ].count();
  cout << ans[ 0 ] << " " << ans[ 1 ] << endl;
  return 0;
}
0