結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー 👑 NachiaNachia
提出日時 2021-07-21 22:23:06
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 11 ms / 2,000 ms
コード長 797 bytes
コンパイル時間 961 ms
コンパイル使用メモリ 82,312 KB
最終ジャッジ日時 2025-01-23 04:34:28
ジャッジサーバーID
(参考情報)
judge2 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(int i=0; i<(n); i++) 


int N,M;
vector<vector<int>> E;
vector<int> I;

int main(){
  cin >> N >> M;
  E.resize(N);
  I.assign(N,0);
  rep(i,M){
    int u,v; cin >> u >> v; u--; v--;
    E[u].push_back(v);
    E[v].push_back(u);
    I[u]++;
    I[v]++;
  }

  int ans = 0;
  while(true){
    int id = -1;
    rep(i,N) if(I[i] == 1) id = i;
    if(id == -1) break;
    I[id]--;
    for(int e : E[id]) I[e]--;
    ans ^= 1;
  }
  cout << vector<string>{"No\n","Yes\n"}[ans];

  return 0;
}

struct ios_do_not_sync{
  ios_do_not_sync(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
  }
} ios_do_not_sync_instance;


0