結果

問題 No.1673 Lamps on a line
ユーザー karinohitokarinohito
提出日時 2021-09-10 22:37:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 196 ms / 2,000 ms
コード長 870 bytes
コンパイル時間 2,373 ms
コンパイル使用メモリ 168,212 KB
実行使用メモリ 6,876 KB
最終ジャッジ日時 2023-09-02 19:14:35
合計ジャッジ時間 4,552 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,368 KB
testcase_01 AC 2 ms
4,368 KB
testcase_02 AC 85 ms
4,368 KB
testcase_03 AC 85 ms
4,368 KB
testcase_04 AC 149 ms
4,372 KB
testcase_05 AC 9 ms
4,368 KB
testcase_06 AC 123 ms
4,368 KB
testcase_07 AC 115 ms
5,996 KB
testcase_08 AC 4 ms
5,148 KB
testcase_09 AC 164 ms
4,368 KB
testcase_10 AC 176 ms
5,164 KB
testcase_11 AC 18 ms
5,404 KB
testcase_12 AC 196 ms
6,876 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

//#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
using ll = long long;
#define all(A) A.begin(),A.end()
using vll = vector<ll>;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
using Graph = vector<vector<ll>>;
Graph G;
vll dist;
vector<bool> seen;
ll mod = 1e9 + 7;

ll inv(ll N) {
    ll a = N, b = mod, c = 1, d = 0;
    while (b > 0) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        c -= t * d;
        swap(c, d);

    }
    c %= mod;
    if (c < 0)c += mod;
    return c;

}

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