結果
問題 |
No.583 鉄道同好会
|
ユーザー |
![]() |
提出日時 | 2017-10-28 00:03:29 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 962 bytes |
コンパイル時間 | 1,682 ms |
コンパイル使用メモリ | 174,732 KB |
実行使用メモリ | 5,976 KB |
最終ジャッジ日時 | 2024-11-21 23:48:30 |
合計ジャッジ時間 | 2,654 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 15 WA * 1 |
ソースコード
#include <bits/stdc++.h> using namespace std; template <typename T> struct graph { struct edge { int from, to; T cost; }; vector<edge> edges; vector<vector<int>> g; int n; graph(int n) : n(n) { g.resize(n); } virtual void add(int from, int to, T cost) = 0; }; template <typename T> struct undirected_graph : graph<T> { using graph<T>::edges; using graph<T>::g; using graph<T>::n; undirected_graph(int n) : graph<T>(n) { } void add(int from, int to, T cost = 1) { assert(0 <= from && from < n && 0 <= to && to < n); g[from].emplace_back(edges.size()); g[to].emplace_back(edges.size()); edges.push_back({from, to, cost}); } }; int main() { int n, m; cin >> n >> m; undirected_graph<int> g(n); for (int i = 0; i < m; i++) { int from, to; cin >> from >> to; g.add(from, to); } int puni = 0; for (auto &v : g.g) { if (v.size() & 1) { puni++; } } cout << (puni < 3 ? "YES" : "NO") << endl; return 0; }