結果

問題 No.1673 Lamps on a line
ユーザー Yug_min_nullYug_min_null
提出日時 2021-09-10 21:25:13
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 207 ms / 2,000 ms
コード長 373 bytes
コンパイル時間 1,808 ms
コンパイル使用メモリ 187,188 KB
実行使用メモリ 4,968 KB
最終ジャッジ日時 2023-09-02 15:48:29
合計ジャッジ時間 4,014 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 86 ms
4,376 KB
testcase_03 AC 85 ms
4,376 KB
testcase_04 AC 149 ms
4,380 KB
testcase_05 AC 9 ms
4,376 KB
testcase_06 AC 130 ms
4,380 KB
testcase_07 AC 119 ms
4,852 KB
testcase_08 AC 4 ms
4,376 KB
testcase_09 AC 169 ms
4,380 KB
testcase_10 AC 180 ms
4,380 KB
testcase_11 AC 17 ms
4,376 KB
testcase_12 AC 207 ms
4,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _GLIBCXX_DEBUG
#define ll long long
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, Q; cin >> N >> Q;
  vector<int> S(N, 0);
  int ans = 0;
  for(int i = 0; i < Q; i++){
    int L, R; cin >> L >> R;
    for(int i = L-1; i <= R-1; i++){
      S[i] = (S[i]+1)%2;
      if(S[i] == 1) ans++;
      else ans--;
    }
    cout << ans << endl;
  }
}

0