結果
| 問題 |
No.408 五輪ピック
|
| コンテスト | |
| ユーザー |
紙ぺーぱー
|
| 提出日時 | 2016-06-05 10:59:55 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 906 bytes |
| コンパイル時間 | 1,913 ms |
| コンパイル使用メモリ | 176,276 KB |
| 実行使用メモリ | 11,468 KB |
| 最終ジャッジ日時 | 2024-10-08 15:34:22 |
| 合計ジャッジ時間 | 9,970 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 24 TLE * 1 -- * 7 |
ソースコード
#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;
}
紙ぺーぱー