結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー milanis48663220milanis48663220
提出日時 2021-07-21 21:26:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,456 bytes
コンパイル時間 1,298 ms
コンパイル使用メモリ 128,152 KB
実行使用メモリ 4,504 KB
最終ジャッジ日時 2023-09-24 15:14:29
合計ジャッジ時間 3,143 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using namespace std;
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int n, m; cin >> n >> m;
    vector<set<int>> g(n);
    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b; a--; b--;
        g[a].insert(b);
        g[b].insert(a);
    }
    queue<int> que;
    for(int i = 0; i < n; i++){
        if(g[i].size() == 1) que.push(i);   
    }
    
    while(!que.empty()){
        int v = que.front(); que.pop();
        for(int to: g[v]){
            if(g[to].count(v)) {
                g[to].erase(v);
                if(g[to].size() == 1) que.push(to);
            }
        }
        g[v].clear();
    }
    for(int i = 0; i < n; i++){
        if(!g[i].empty()){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
0