結果

問題 No.1673 Lamps on a line
ユーザー milanis48663220milanis48663220
提出日時 2021-09-10 21:22:54
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 147 ms / 2,000 ms
コード長 1,109 bytes
コンパイル時間 1,018 ms
コンパイル使用メモリ 117,552 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-02 15:41:37
合計ジャッジ時間 2,769 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 72 ms
4,376 KB
testcase_03 AC 69 ms
4,380 KB
testcase_04 AC 123 ms
4,376 KB
testcase_05 AC 8 ms
4,380 KB
testcase_06 AC 107 ms
4,380 KB
testcase_07 AC 86 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 128 ms
4,380 KB
testcase_10 AC 132 ms
4,376 KB
testcase_11 AC 13 ms
4,380 KB
testcase_12 AC 147 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n, q; cin >> n >> q;
    vector<bool> on(n, false);
    int cnt = 0;
    for(int i = 0; i < q; i++){
        int l, r; cin >> l >> r; l--; r--;
        for(int j = l; j <= r; j++) {
            if(on[j]){
                cnt--;
            }else{
                cnt++;
            }
            on[j] = !on[j];
        }
        cout << cnt << endl;
    }
}
0