結果

問題 No.1673 Lamps on a line
ユーザー okkuukenkenokkuukenken
提出日時 2022-07-19 12:50:42
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 473 bytes
コンパイル時間 1,292 ms
コンパイル使用メモリ 128,732 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-14 07:24:18
合計ジャッジ時間 3,982 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 83 ms
4,376 KB
testcase_03 AC 84 ms
4,380 KB
testcase_04 AC 145 ms
4,380 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 125 ms
4,376 KB
testcase_07 AC 112 ms
4,380 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 164 ms
4,376 KB
testcase_10 AC 171 ms
4,376 KB
testcase_11 AC 16 ms
4,376 KB
testcase_12 AC 193 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<iomanip>
#include<numeric>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<random>
using namespace std;
typedef long long ll;
const int mod=1e9+7;
bool tmp[500000];
int main(){
	int n,q,l,r;
	cin>>n>>q;
	int ans=0;
	while(cin>>l>>r){
		l--;
		for(int i=l;i<r;i++){
			ans-=tmp[i];
			tmp[i]^=1;
			ans+=tmp[i];
		}
		cout<<ans<<endl;
	}
}
0