結果

問題 No.408 五輪ピック
ユーザー 紙ぺーぱー紙ぺーぱー
提出日時 2016-06-05 02:13:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 897 bytes
コンパイル時間 1,754 ms
コンパイル使用メモリ 171,052 KB
実行使用メモリ 12,160 KB
最終ジャッジ日時 2024-04-17 04:18:32
合計ジャッジ時間 9,612 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 1 ms
5,376 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 52 ms
8,320 KB
testcase_06 AC 42 ms
5,888 KB
testcase_07 AC 67 ms
7,000 KB
testcase_08 AC 38 ms
6,920 KB
testcase_09 AC 40 ms
6,804 KB
testcase_10 AC 39 ms
6,016 KB
testcase_11 AC 45 ms
5,888 KB
testcase_12 AC 86 ms
7,716 KB
testcase_13 AC 50 ms
8,064 KB
testcase_14 AC 18 ms
5,376 KB
testcase_15 AC 54 ms
8,320 KB
testcase_16 AC 54 ms
8,320 KB
testcase_17 AC 57 ms
8,448 KB
testcase_18 AC 60 ms
8,320 KB
testcase_19 AC 82 ms
8,320 KB
testcase_20 AC 15 ms
5,376 KB
testcase_21 AC 9 ms
5,376 KB
testcase_22 AC 25 ms
5,632 KB
testcase_23 AC 61 ms
8,448 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);
  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