結果

問題 No.408 五輪ピック
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2016-06-05 10:59:55
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 906 bytes
コンパイル時間 1,745 ms
コンパイル使用メモリ 172,936 KB
実行使用メモリ 13,276 KB
最終ジャッジ日時 2024-04-17 04:45:31
合計ジャッジ時間 9,354 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 40 ms
8,336 KB
testcase_06 AC 40 ms
5,760 KB
testcase_07 AC 67 ms
6,568 KB
testcase_08 AC 27 ms
6,296 KB
testcase_09 AC 29 ms
6,416 KB
testcase_10 AC 39 ms
5,760 KB
testcase_11 AC 41 ms
5,888 KB
testcase_12 AC 94 ms
6,996 KB
testcase_13 AC 39 ms
8,316 KB
testcase_14 AC 20 ms
5,376 KB
testcase_15 AC 39 ms
8,592 KB
testcase_16 AC 43 ms
8,332 KB
testcase_17 AC 46 ms
8,336 KB
testcase_18 AC 48 ms
8,332 KB
testcase_19 AC 64 ms
8,208 KB
testcase_20 AC 14 ms
5,376 KB
testcase_21 AC 8 ms
5,376 KB
testcase_22 AC 23 ms
5,376 KB
testcase_23 AC 47 ms
8,376 KB
testcase_24 TLE -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  vector<int>from(m),to(m);
  unordered_set<long long> s;
  vector<int>adj;
  for(int i=0;i<m;i++){
    cin>>from[i]>>to[i];
    from[i]--;to[i]--;
    if(from[i]==0)adj.emplace_back(to[i]);
    if(to[i]==0)adj.emplace_back(from[i]);
    s.emplace(from[i]*100000+to[i]);
    s.emplace(to[i]*100000+from[i]);
  }
  for(int i=0;i<m;i++){
    if(from[i]==0)continue;
    if(to[i]==0)continue;
    int a=0,b=0,c=0;
    for(auto& j:adj){
      if(j==from[i])continue;
      if(j==to[i])continue;
      if(!s.count(j))continue;
      int x=0;
      if(s.count(j*100000+from[i]))x|=1;
      if(s.count(j*100000+to[i]))x|=2;
      if(x==1)a++;
      else if(x==2)b++;
      else if(x==3)c++;
      if((a>0&&b>0)||(a>0&&c>0)||(b>0&&c>0)||(c>=2)){
        cout<<"YES"<<endl;
        return 0;
      }

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