結果

問題 No.1673 Lamps on a line
ユーザー 沙耶花沙耶花
提出日時 2021-09-10 21:24:52
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 4,542 ms
コンパイル使用メモリ 262,540 KB
実行使用メモリ 17,244 KB
最終ジャッジ日時 2023-09-02 15:47:46
合計ジャッジ時間 5,902 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 15 ms
4,380 KB
testcase_03 AC 14 ms
4,376 KB
testcase_04 AC 25 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 22 ms
4,380 KB
testcase_07 AC 48 ms
16,276 KB
testcase_08 AC 10 ms
15,632 KB
testcase_09 AC 53 ms
6,360 KB
testcase_10 AC 64 ms
10,144 KB
testcase_11 AC 11 ms
10,132 KB
testcase_12 AC 61 ms
17,244 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000001

using P = pair<int,int> ;

P op(P a,P b){
	a.first += b.first;
	a.second += b.second;
	return a;
}

P e(){
	return make_pair(0,0);
}

P mapping(int a,P b){
	rep(i,(a&1))swap(b.first,b.second);
	return b;
}

int composition(int a,int b){
	return ((a+b)&1);
}

int id(){
	return 0;
}

int main(){
	
	int N,Q;
	cin>>N>>Q;
	vector<P> t(N,make_pair(1,0));
	lazy_segtree<P,op,e,int,mapping,composition,id> seg(t);
	
	
	rep(i,Q){
		int l,r;
		scanf("%d %d",&l,&r);
		l--;
		seg.apply(l,r,1);
		printf("%d\n",seg.all_prod().second);
	}
	
	return 0;
}
0