結果

問題 No.1673 Lamps on a line
ユーザー 👑 NachiaNachia
提出日時 2021-09-10 21:56:53
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 673 bytes
コンパイル時間 618 ms
コンパイル使用メモリ 77,028 KB
実行使用メモリ 4,968 KB
最終ジャッジ日時 2023-09-02 17:16:17
合計ジャッジ時間 1,720 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,372 KB
testcase_01 AC 1 ms
4,368 KB
testcase_02 AC 10 ms
4,372 KB
testcase_03 AC 11 ms
4,372 KB
testcase_04 AC 18 ms
4,368 KB
testcase_05 AC 2 ms
4,368 KB
testcase_06 AC 16 ms
4,368 KB
testcase_07 AC 18 ms
4,604 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 23 ms
4,368 KB
testcase_10 AC 26 ms
4,368 KB
testcase_11 AC 5 ms
4,368 KB
testcase_12 AC 28 ms
4,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <atcoder/segtree>
#include <atcoder/lazysegtree>
using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(n); i++)




int main(){
  int N,Q; cin >> N >> Q;
  vector<int> A(N,0);
  int ans = 0;
  rep(i,Q){
    int l,r; cin >> l >> r; l--;
    for(int p=l; p<r; p++){
      ans -= A[p];
      A[p] ^= 1;
      ans += A[p];
    }
    cout << ans << "\n";
  }
  return 0;
}




struct ios_do_not_sync {
    ios_do_not_sync() {
        ios::sync_with_stdio(false);
        cin.tie(nullptr);
    }
} ios_do_not_sync_instance;
0