結果
| 問題 | No.230 Splarraay スプラレェーイ | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2017-04-27 19:14:13 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 1,567 ms / 5,000 ms | 
| コード長 | 855 bytes | 
| コンパイル時間 | 1,594 ms | 
| コンパイル使用メモリ | 171,808 KB | 
| 実行使用メモリ | 6,944 KB | 
| 最終ジャッジ日時 | 2024-09-13 14:51:31 | 
| 合計ジャッジ時間 | 14,021 ms | 
| ジャッジサーバーID (参考情報) | judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 17 | 
ソースコード
#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;
}
            
            
            
        