結果

問題 No.1673 Lamps on a line
ユーザー auauaauaua
提出日時 2021-09-10 21:25:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 2,000 ms
コード長 1,135 bytes
コンパイル時間 1,695 ms
コンパイル使用メモリ 166,460 KB
実行使用メモリ 6,860 KB
最終ジャッジ日時 2023-09-02 15:49:21
合計ジャッジ時間 2,532 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,360 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 10 ms
4,376 KB
testcase_03 AC 11 ms
4,380 KB
testcase_04 AC 16 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 13 ms
4,376 KB
testcase_07 AC 19 ms
5,856 KB
testcase_08 AC 3 ms
5,228 KB
testcase_09 AC 23 ms
4,376 KB
testcase_10 AC 28 ms
4,964 KB
testcase_11 AC 5 ms
5,080 KB
testcase_12 AC 29 ms
6,860 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#include<random>
using namespace std;
//#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
//#define vec vector<ll>
//#define mat vector<vector<ll> >
#define fi first
#define se second
//#define double long double
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
//typedef long double ld;
typedef complex<double> Complex;
const ll INF=1e9+7;
const ll MOD=998244353;
const ll inf=INF*INF;
const ll mod=MOD;
const ll MAX=1000000;
const double PI=acos(-1.0);
typedef vector<vector<ll> > mat;
typedef vector<ll> vec;


void solve(){
    ll n,q;cin>>n>>q;
    vector<ll>a(n+1);
    ll now=0;
    rep(i,q){
        ll l,r;cin>>l>>r;
        l--;
        REP(j,l,r){
            a[j]++;
            if(a[j]%2){
                now++;
            }else{
                now--;
            }
        }
        cout<<now<<endl;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
}
0