結果

問題 No.230 Splarraay スプラレェーイ
ユーザー koyumeishikoyumeishi
提出日時 2015-06-11 04:59:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 1,353 ms / 5,000 ms
コード長 963 bytes
コンパイル時間 566 ms
コンパイル使用メモリ 77,376 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-25 02:10:50
合計ジャッジ時間 11,597 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 74 ms
4,380 KB
testcase_07 AC 9 ms
4,380 KB
testcase_08 AC 33 ms
4,376 KB
testcase_09 AC 667 ms
4,376 KB
testcase_10 AC 1,169 ms
4,376 KB
testcase_11 AC 309 ms
4,380 KB
testcase_12 AC 661 ms
4,380 KB
testcase_13 AC 98 ms
4,376 KB
testcase_14 AC 1,353 ms
4,376 KB
testcase_15 AC 1,303 ms
4,376 KB
testcase_16 AC 1,267 ms
4,380 KB
testcase_17 AC 1,303 ms
4,380 KB
testcase_18 AC 1,059 ms
4,376 KB
testcase_19 AC 559 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <cstdio>
#include <sstream>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <cmath>
#include <set>
#include <bitset>
using namespace std;

#define LEN 100000

int main(){
	int n,q;
	cin >> n >> q;
	long long ans_a = 0;
	long long ans_b = 0;

	bitset<LEN> a;
	bitset<LEN> b;
	bitset<LEN> mask;
	for(int i=0; i<q; i++){
		int x,l,r;
		cin >> x >> l >> r;

		mask.reset();
		mask.flip();
		int d = LEN - (r+1 - l);
		mask >>= d;
		mask <<= l;

		if(x==0){
			int cnt_a = (a & mask).count();
			int cnt_b = (b & mask).count();

			if(cnt_a == cnt_b) continue;
			(cnt_a>cnt_b?ans_a:ans_b) += max(cnt_a, cnt_b);

		}else{
			if(x==1){
				a |= mask;
				mask.flip();
				b &= mask;
			}else{
				b |= mask;
				mask.flip();
				a &= mask;
			}
		}
	}


	int cnt_a = a.count();
	int cnt_b = b.count();

	ans_a += cnt_a;
	ans_b += cnt_b;

	cout << ans_a << " " << ans_b << endl;
	return 0;
}
0