結果
| 問題 |
No.583 鉄道同好会
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2017-10-27 23:01:11 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,592 bytes |
| コンパイル時間 | 1,911 ms |
| コンパイル使用メモリ | 177,180 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-21 22:39:07 |
| 合計ジャッジ時間 | 2,639 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 12 WA * 4 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))
using ll = long long;
using P = std::tuple<int,int>;
const int dx[8] = {-1, 1, 0, 0, -1, -1, 1, 1}, dy[8] = {0, 0, -1, 1, -1, 1, -1, 1};
int N, M;
vector<int> G[510];
vector<P> ps;
bool used[510*510], used2[510];
bool f(){
int odd_n = 0;
for(int i=0;i<M;++i){
int a, b;
tie(a, b) = ps[i];
if((G[a].size() + G[b].size()) % 2 == 1){
++odd_n;
}
}
return odd_n == 0 || odd_n == 2;
}
bool g(){
for(int i=0;i<M;++i){
if(!used[i]){
return false;
}
}
return true;
}
void dfs(int e){
int a, b;
tie(a, b) = ps[e];
used[e] = true;
used2[a] = true;
used2[b] = true;
for(int e2 : G[a]){
int a2, b2;
tie(a2, b2) = ps[e2];
if(!used[e2] && !used2[a ^ a2 ^ b2]){
dfs(e2);
}
}
for(int e2 : G[b]){
int a2, b2;
tie(a2, b2) = ps[e2];
if(!used[e2] && !used2[a ^ a2 ^ b2]){
dfs(e2);
}
}
}
int main(){
std::cin.tie(nullptr);
std::ios::sync_with_stdio(false);
std::cin >> N >> M;
for(int i=0;i<M;++i){
int a, b;
std::cin >> a >> b;
ps.emplace_back(a, b);
G[a].emplace_back(i);
G[b].emplace_back(i);
}
dfs(0);
const string YESNO[2] = {"NO", "YES"};
std::cout << YESNO[(f() && g())] << std::endl;
}
tottoripaper