結果

問題 No.1673 Lamps on a line
ユーザー 沙耶花
提出日時 2021-09-10 21:24:52
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 77 ms / 2,000 ms
コード長 726 bytes
コンパイル時間 4,715 ms
コンパイル使用メモリ 253,580 KB
最終ジャッジ日時 2025-01-24 09:32:39
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:44:22: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   44 |                 scanf("%d %d",&l,&r);
      |                 ~~~~~^~~~~~~~~~~~~~~

ソースコード

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