結果

問題 No.408 五輪ピック
ユーザー latte0119latte0119
提出日時 2016-08-05 22:44:59
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,421 bytes
コンパイル時間 1,338 ms
コンパイル使用メモリ 161,928 KB
実行使用メモリ 7,308 KB
最終ジャッジ日時 2024-04-24 15:56:27
合計ジャッジ時間 3,323 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int N,M;
vint G[20000];

bool f[20000];
int A[50000],B[50000];

vint T[20000];

signed main(){
    cin>>N>>M;
    rep(i,M){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].pb(b);G[b].pb(a);
        A[i]=a;B[i]=b;
    }


    for(auto v:G[0])f[v]=true;


    rep(i,N)for(auto u:G[i]){
        if(f[u])T[i].pb(u);
    }

    rep(i,M){
        if(A[i]==1||B[i]==1)continue;
        cout<<A[i]<<" "<<B[i]<<endl;
        for(int j=0;j<min((int)T[A[i]].size(),3ll);j++){
            for(int k=0;k<min((int)T[B[i]].size(),3ll);k++){
                int a=T[A[i]][j];
                int b=T[B[i]][k];
                if(a==B[i])continue;
                if(b==A[i])continue;
                if(a==b)continue;
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }

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