結果
問題 | No.1610 She Loves Me, She Loves Me Not, ... |
ユーザー |
|
提出日時 | 2022-10-03 20:39:11 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 2,000 ms |
コード長 | 709 bytes |
コンパイル時間 | 1,831 ms |
コンパイル使用メモリ | 201,276 KB |
最終ジャッジ日時 | 2025-02-07 20:54:36 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 32 |
ソースコード
#include <bits/stdc++.h> #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; int main(){ cin.tie(0); ios::sync_with_stdio(0); int N,M; cin >> N >> M; vector<vector<int>> G(N); vector<int> deg(N, 0); rep(i,M) { int a,b; cin >> a >> b; a--; b--; G[a].push_back(b); G[b].push_back(a); deg[a]++, deg[b]++; } queue<int> q; rep(i,N) if(deg[i] == 1) q.push(i); int cnt = 0; while(!q.empty()) { int v = q.front(); q.pop(); if(deg[v] == 0) continue; cnt++; for(int to : G[v]) if(--deg[to] == 1) q.push(to); } cout << (cnt % 2 == 1 ? "Yes" : "No") << endl; }