結果

問題 No.1610 She Loves Me, She Loves Me Not, ...
ユーザー SSRS
提出日時 2021-07-21 21:26:52
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 14 ms / 2,000 ms
コード長 754 bytes
コンパイル時間 1,870 ms
コンパイル使用メモリ 171,192 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-17 16:00:35
合計ジャッジ時間 3,092 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M;
  cin >> N >> M;
  vector<vector<int>> E(N);
  for (int i = 0; i < M; i++){
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    E[A].push_back(B);
    E[B].push_back(A);
  }
  int cnt = 0;
  while (true){
    int p = -1;
    for (int i = 0; i < N; i++){
      if (E[i].size() == 1){
        p = i;
      }
    }
    if (p == -1){
      break;
    } else {
      int p2 = E[p][0];
      E[p].clear();
      int d = E[p2].size();
      for (int i = 0; i < d; i++){
        if (E[p2][i] == p){
          E[p2].erase(E[p2].begin() + i);
          break;
        }
      }
      cnt++;
    }
  }
  if (cnt % 2 == 1){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}
0