結果

問題 No.1673 Lamps on a line
ユーザー ekaraageekaraage
提出日時 2021-08-02 13:10:11
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 193 ms / 2,000 ms
コード長 1,001 bytes
コンパイル時間 4,938 ms
コンパイル使用メモリ 259,820 KB
実行使用メモリ 7,180 KB
最終ジャッジ日時 2023-09-02 15:02:28
合計ジャッジ時間 6,275 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 84 ms
4,376 KB
testcase_03 AC 81 ms
4,376 KB
testcase_04 AC 147 ms
4,380 KB
testcase_05 AC 8 ms
4,376 KB
testcase_06 AC 121 ms
4,376 KB
testcase_07 AC 113 ms
5,960 KB
testcase_08 AC 5 ms
5,136 KB
testcase_09 AC 162 ms
4,376 KB
testcase_10 AC 176 ms
4,976 KB
testcase_11 AC 18 ms
5,232 KB
testcase_12 AC 193 ms
7,180 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using ll = long long;
constexpr long long MOD = 1000000007;
constexpr long long MOD2 = 998244353;
constexpr long long INF = 1LL << 60;
const long double PI = acosl(-1.0);
constexpr long double EPS = 1e-11;
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
int main(){
    ll N, Q;
    cin >> N >> Q;
    vector<ll> A(N, 0);
    assert(N <= 500000);
    assert(Q <= 100000);
    ll ans = 0;
    while (Q--) {
        ll l, r;
        cin >> l >> r;
        assert(1 <= l and l <= N);
        assert(l <= r and r <= N);
        assert(r - l <= 10);
        l--;
        r--;
        for (ll i = l; i <= r;i++){
            A[i] ^= 1;
            if (A[i] == 1)
                ans++;
            else
                ans--;
        }
        cout << ans << endl;
    }
}
0