結果
| 問題 |
No.1610 She Loves Me, She Loves Me Not, ...
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-02 20:20:33 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 7 ms / 2,000 ms |
| コード長 | 1,099 bytes |
| コンパイル時間 | 2,150 ms |
| コンパイル使用メモリ | 205,084 KB |
| 最終ジャッジ日時 | 2025-02-07 00:37:36 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 32 |
ソースコード
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;
}
}