結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー erbowlerbowl
提出日時 2022-09-02 20:20:33
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 1,099 bytes
コンパイル時間 2,299 ms
コンパイル使用メモリ 212,752 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-27 19:49:22
合計ジャッジ時間 3,701 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 AC 2 ms
6,944 KB
testcase_04 AC 2 ms
6,940 KB
testcase_05 AC 7 ms
6,944 KB
testcase_06 AC 6 ms
6,940 KB
testcase_07 AC 6 ms
6,944 KB
testcase_08 AC 6 ms
6,940 KB
testcase_09 AC 7 ms
6,944 KB
testcase_10 AC 7 ms
6,940 KB
testcase_11 AC 6 ms
6,944 KB
testcase_12 AC 7 ms
6,944 KB
testcase_13 AC 6 ms
6,944 KB
testcase_14 AC 2 ms
6,940 KB
testcase_15 AC 2 ms
6,944 KB
testcase_16 AC 2 ms
6,940 KB
testcase_17 AC 2 ms
6,940 KB
testcase_18 AC 2 ms
6,944 KB
testcase_19 AC 2 ms
6,940 KB
testcase_20 AC 2 ms
6,944 KB
testcase_21 AC 2 ms
6,944 KB
testcase_22 AC 2 ms
6,940 KB
testcase_23 AC 1 ms
6,944 KB
testcase_24 AC 2 ms
6,940 KB
testcase_25 AC 2 ms
6,940 KB
testcase_26 AC 2 ms
6,940 KB
testcase_27 AC 2 ms
6,940 KB
testcase_28 AC 2 ms
6,944 KB
testcase_29 AC 2 ms
6,944 KB
testcase_30 AC 2 ms
6,940 KB
testcase_31 AC 2 ms
6,940 KB
testcase_32 AC 2 ms
6,940 KB
testcase_33 AC 2 ms
6,940 KB
testcase_34 AC 2 ms
6,940 KB
testcase_35 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

typedef long long ll;
typedef long double ld;
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
    ll n,m;
    std::cin >> n>>m;
    vector<ll> v(n);
    vector<vector<pair<ll,ll>>> edges(n);
    for (int i = 0; i < m; i++) {
        ll a,b;
        std::cin >> a>>b;
        a--;b--;
        v[a]++;
        v[b]++;
        edges[a].push_back({b,i});
        edges[b].push_back({a,i});
    }
    vector<bool> used(m);
    priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>> pq;
    for (int i = 0; i < n; i++) {
        pq.push({v[i],i});
    }
    bool ok = true;
    while(pq.size()){
        auto [val, now] = pq.top();pq.pop();
        val = v[now];
        if(val!=1)continue;
        v[now]--;
        ok = !ok;
        for (auto e : edges[now]) {
            auto [ee, ii] = e;
            if(used[ii])continue;
            v[ee]--;
            pq.push({v[ee],ee});
            used[ii]=true;
            break;
        }
    }
    if(ok){
        std::cout << "No" << std::endl;
    }else{
        std::cout << "Yes" << std::endl;
    }
}
0