結果

問題 No.1673 Lamps on a line
ユーザー たまごんたまごん
提出日時 2021-09-10 21:40:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 488 bytes
コンパイル時間 1,639 ms
コンパイル使用メモリ 166,320 KB
実行使用メモリ 4,860 KB
最終ジャッジ日時 2023-09-02 16:26:10
合計ジャッジ時間 3,016 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int main()’ 内:
main.cpp:21:11: 警告: ‘b’ may be used uninitialized [-Wmaybe-uninitialized]
   21 |         b += x;
      |         ~~^~~~
main.cpp:19:9: 備考: ‘b’ はここで定義されています
   19 |     int b;
      |         ^

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const long long INF = 1LL << 60;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()

int main() {
    int n, q, ans = 0;
    cin >> n >> q;
    vector<int> a(n+1);
    rep(i,q){
        int l, r;
        cin >>  l >> r;
        a[l]++;
        a[r]++;
    }
    int b;
    for(int x : a){
        b += x;
        if(b%2==1) ans++;
    }
    cout << ans << endl;
}
0