結果
| 問題 | No.408 五輪ピック |
| コンテスト | |
| ユーザー |
sugarrr
|
| 提出日時 | 2018-08-29 00:13:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,556 bytes |
| 記録 | |
| コンパイル時間 | 874 ms |
| コンパイル使用メモリ | 101,964 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-18 12:16:20 |
| 合計ジャッジ時間 | 2,377 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 27 WA * 5 |
ソースコード
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<string>
#include<iostream>
#include<set>
#include<map>
#include<bitset>
using namespace std;
typedef long long ll;
#define i_7 (ll)(1E9+7)
#define i_5 (ll)(1E9+5)
ll mod(ll a){
ll c=a%i_7;
if(c>=0)return c;
else return c+i_7;
}
typedef pair<int,int> i_i;
typedef pair<ll,ll> l_l;
ll inf=(ll)1E12;/*10^12*/
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
////////////////////////////////////////
bool check(vector<int>v,vector<int>u){
sort(v.begin(),v.end());
v.erase(unique(v.begin(),v.end()),v.end());
sort(u.begin(),u.end());
u.erase(unique(u.begin(),u.end()),u.end());
set<int>s;
ll vv=v.size(),uu=u.size();
for(auto x:v)s.insert(x);
for(auto x:u)s.insert(x);
ll ss=s.size();
return ss==vv+uu;
}
int main(){
int n,m;cin>>n>>m;
vector<int>v[n];
rep(i,0,m-1){
int s,t;cin>>s>>t;s--;t--;
v[s].pb(t);
v[t].pb(s);
}
vector<int>v0,v1,v2;
for(auto x:v[0])v0.pb(x);
for(auto x:v0){
for(auto y:v[x])v1.pb(y);
}
sort(v1.begin(),v1.end());
v1.erase(unique(v1.begin(),v1.end()),v1.end());
for(auto x:v1){
for(auto y:v[x])v2.pb(y);
}
if(!check(v1,v2)){
cout<<"YES"<<endl;
}else{
cout<<"NO"<<endl;
}
return 0;
}
sugarrr