結果

問題 No.408 五輪ピック
コンテスト
ユーザー tossy
提出日時 2016-08-05 23:04:53
言語 C++14
(gcc 15.2.0 + boost 1.89.0)
コンパイル:
g++-15 -O2 -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,125 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 759 ms
コンパイル使用メモリ 104,904 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-05-07 07:58:38
合計ジャッジ時間 7,845 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 22 WA * 3 TLE * 1 -- * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

#define N 20000
vector<int> g[N];
bool  visited[N];

int from;
bool dfs(int f, int d){
  if(d==0){ from=f; fill(visited, visited+N, false); }
  if(d==4){
    rep(i,g[f].size()) if(g[f][i]==from) return true;
    return false;
  }
  visited[f]=true;
  rep(i,g[f].size()) if(!visited[g[f][i]] && dfs(g[f][i], d+1)) return true;
  visited[f]=false;
  return false;
}

int main(){
  int n,m;
  cin>>n>>m;
  rep(i,m){
    int a,b;
    scanf("%d %d", &a, &b);
    a--;b--;
    g[a].pb(b);
    g[b].pb(a);
  }

  if(dfs(1,0)){
    cout<<"YES"<<endl;
    return 0;
  }

  cout<<"NO"<<endl;
  return 0;
}
0