結果

問題 No.629 グラフの中に眠る門松列
ユーザー dustnn0dustnn0
提出日時 2018-03-10 17:40:54
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 86 ms / 4,000 ms
コード長 928 bytes
コンパイル時間 1,605 ms
コンパイル使用メモリ 164,944 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-22 16:44:53
合計ジャッジ時間 3,776 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 2 ms
5,376 KB
testcase_10 AC 2 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 2 ms
5,376 KB
testcase_14 AC 2 ms
5,376 KB
testcase_15 AC 1 ms
5,376 KB
testcase_16 AC 2 ms
5,376 KB
testcase_17 AC 2 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 2 ms
5,376 KB
testcase_20 AC 2 ms
5,376 KB
testcase_21 AC 81 ms
7,424 KB
testcase_22 AC 5 ms
7,424 KB
testcase_23 AC 5 ms
7,552 KB
testcase_24 AC 3 ms
5,376 KB
testcase_25 AC 4 ms
5,376 KB
testcase_26 AC 4 ms
5,376 KB
testcase_27 AC 36 ms
7,424 KB
testcase_28 AC 83 ms
5,760 KB
testcase_29 AC 28 ms
7,424 KB
testcase_30 AC 44 ms
7,424 KB
testcase_31 AC 48 ms
7,424 KB
testcase_32 AC 15 ms
7,424 KB
testcase_33 AC 86 ms
7,552 KB
testcase_34 AC 20 ms
7,424 KB
testcase_35 AC 16 ms
7,296 KB
testcase_36 AC 12 ms
7,552 KB
testcase_37 AC 85 ms
7,552 KB
testcase_38 AC 11 ms
7,552 KB
testcase_39 AC 10 ms
7,552 KB
testcase_40 AC 83 ms
7,296 KB
testcase_41 AC 29 ms
7,424 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,a) for(int i=0;i<(a);i++)
#define MOD 1000000007

int p[1000][1000];

int main(){
  int n,m; cin>>n>>m;
  int a[n];
  rep(i,n) cin>>a[i];
  rep(i,m){
    int x,y; cin>>x>>y;
    x--, y--;
    p[x][y]=p[y][x]=1;
  }
  for(int i=0;i<n-2;i++){
    for(int j=i+1;j<n-1;j++){
      for(int k=j+1;k<n;k++){
        if(a[i]==a[j]||a[i]==a[k]||a[j]==a[k]) continue;
        int ma=max({a[i],a[j],a[k]});
        int mi=min({a[i],a[j],a[k]});
        int v[3]={i,j,k};
        do{
          bool flag1=p[v[0]][v[1]]&&p[v[1]][v[2]];
          bool flag2=(a[v[1]]==ma)||(a[v[1]]==mi);
          if(flag1&&flag2){
            //cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<endl;
            cout<<"YES"<<endl;
            return 0;
          }
        }while(next_permutation(v,v+3));
      }
    }
  }
  cout<<"NO"<<endl;
  return 0;
}
0