結果

問題 No.408 五輪ピック
ユーザー beetbeet
提出日時 2018-11-12 16:42:26
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 877 bytes
コンパイル時間 1,917 ms
コンパイル使用メモリ 205,880 KB
最終ジャッジ日時 2025-01-06 16:31:00
ジャッジサーバーID
(参考情報)
judge4 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  int n,m;
  cin>>n>>m;
  vector<vector<int> > G(n);
  for(int i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--;b--;
    G[a].emplace_back(b);
    G[b].emplace_back(a);
  }
  vector<set<int> > vs(n);
  for(int v:G[0]){
    for(int u:G[v]){
      if(u!=0) vs[u].emplace(v);
      if(vs[u].size()>5u) vs[u].erase(vs[u].begin());      
    }
  }
  auto YES=[](){cout<<"YES"<<endl;exit(0);};
  for(int v=0;v<n;v++){
    for(int u:G[v]){
      if(v==0||u==0) continue;
      for(int x:vs[v])
        for(int y:vs[u])
          if(set<int>({0,u,v,x,y}).size()==5u) YES();      
    }
  }
  cout<<"NO"<<endl;
  return 0;
}
0