結果

問題 No.1673 Lamps on a line
ユーザー kuhakukuhaku
提出日時 2021-09-10 22:46:44
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 195 ms / 2,000 ms
コード長 2,133 bytes
コンパイル時間 2,105 ms
コンパイル使用メモリ 199,340 KB
実行使用メモリ 4,372 KB
最終ジャッジ日時 2023-09-02 19:53:25
合計ジャッジ時間 4,217 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,368 KB
testcase_01 AC 2 ms
4,372 KB
testcase_02 AC 83 ms
4,372 KB
testcase_03 AC 83 ms
4,372 KB
testcase_04 AC 146 ms
4,368 KB
testcase_05 AC 9 ms
4,368 KB
testcase_06 AC 123 ms
4,368 KB
testcase_07 AC 108 ms
4,372 KB
testcase_08 AC 2 ms
4,372 KB
testcase_09 AC 160 ms
4,368 KB
testcase_10 AC 172 ms
4,368 KB
testcase_11 AC 16 ms
4,368 KB
testcase_12 AC 195 ms
4,368 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using ld = long double;
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define FORR(i, m, n) for(int i = (m)-1; i >= (n); --i)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FOR(i, 1, n+1)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n+1, 1)
#define all(s) (s).begin(), (s).end()
template <class T, class U>
bool chmax(T &a, const U b) { return a < b ? a = b, true : false; }
template <class T, class U>
bool chmin(T &a, const U b) { return b < a ? a = b, true : false; }
template <class T>
istream &operator>>(istream &is, vector<T> &v) { for (T &i : v) is>>i; return is; }
template <class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    for (auto it=v.begin(); it!=v.end(); ++it) { os<<(it==v.begin()?"":" ")<<*it; } return os;
}
template <class Head, class... Tail>
void co(Head&& head, Tail&&... tail) {
    if constexpr(sizeof...(tail)==0) cout<<head<<'\n'; else cout<<head<<' ',co(forward<Tail>(tail)...);
}
template <class Head, class... Tail>
void ce(Head&& head, Tail&&... tail) {
    if constexpr(sizeof...(tail)==0) cerr<<head<<'\n'; else cerr<<head<<' ',ce(forward<Tail>(tail)...);
}
template<typename T, typename... Args>
auto make_vector(T x, int arg, Args ...args) {
    if constexpr(sizeof...(args)==0) return vector<T>(arg, x); else return vector(arg,make_vector<T>(x, args...));
}
void sonic() { ios::sync_with_stdio(false); cin.tie(nullptr); }
void setp(const int n) { cout << fixed << setprecision(n); }
constexpr int64_t INF = 1000000000000000003;
constexpr int Inf = 1000000003;
constexpr int MOD = 1000000007;
constexpr int MOD_N = 998244353;
constexpr double EPS = 1e-7;
const double PI = acos(-1);

// clang-format on

int main(void) {
    int n, q;
    cin >> n >> q;
    bitset<500001> is_on;
    int sum = 0;
    rep(i, q) {
        int l, r;
        cin >> l >> r;
        FOR(i, l - 1, r) {
            if (is_on[i]) {
                --sum;
            } else {
                ++sum;
            }
            is_on[i].flip();
        }
        co(sum);
    }

    return 0;
}
0