結果

問題 No.1673 Lamps on a line
ユーザー karaagekaraage
提出日時 2021-09-11 17:11:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 2,000 ms
コード長 792 bytes
コンパイル時間 1,781 ms
コンパイル使用メモリ 166,256 KB
実行使用メモリ 5,612 KB
最終ジャッジ日時 2023-09-05 04:52:38
合計ジャッジ時間 3,165 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,384 KB
testcase_01 AC 2 ms
4,384 KB
testcase_02 AC 20 ms
4,380 KB
testcase_03 AC 21 ms
4,384 KB
testcase_04 AC 35 ms
4,380 KB
testcase_05 AC 4 ms
4,384 KB
testcase_06 AC 30 ms
4,380 KB
testcase_07 AC 42 ms
4,784 KB
testcase_08 AC 3 ms
4,384 KB
testcase_09 AC 57 ms
4,384 KB
testcase_10 AC 63 ms
4,608 KB
testcase_11 AC 7 ms
4,380 KB
testcase_12 AC 69 ms
5,612 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ull=unsigned long long;
const ll MOD=1000000000+7;
#define rep(I,N) for(int I=0;I<N;I++)
#define ALL(x) x.begin(),x.end()
#define PRINTV(x) for(auto i:x){for(auto j:i){printf("%d\t",j);}printf("\n");}
using vec = vector<int>;
using vvec = vector<vector<int>>;

ll lcm(ll a,ll b){
    return a/__gcd(a,b)*b;
}

int main(){
    int n,q;
    int sum=0;
    cin >> n >> q;
    vec ans;
    vec a(n,0);
    rep(i,q){
        int l,r;
        cin >> l >> r;
        for(int i=l-1;i<=r-1;i++){
            if(a[i]==0){
                sum++;
                a[i]=1;
            }else{
                sum--;
                a[i]=0;
            }
        }
        ans.push_back(sum);
    }
    for(auto i:ans)printf("%d\n",i);
}
0