結果

問題 No.1673 Lamps on a line
ユーザー keisuke6keisuke6
提出日時 2022-09-21 22:43:25
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 216 ms / 2,000 ms
コード長 391 bytes
コンパイル時間 1,895 ms
コンパイル使用メモリ 195,216 KB
最終ジャッジ日時 2025-02-07 13:28:08
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
    int N,Q;
    cin>>N>>Q;
    vector<bool> S(N);
    int ans = 0;
    for(int i=0;i<Q;i++){
        int l,r;
        cin>>l>>r;
        l--;
        r--;
        for(int j=l;j<=r;j++){
            if(S[j]) ans--;
            else ans++;
            S[j] = !S[j];
        }
        cout<<ans<<endl;
    }
}
0