結果
| 問題 | No.629 グラフの中に眠る門松列 | 
| コンテスト | |
| ユーザー |  totori_nyaa | 
| 提出日時 | 2019-07-17 21:44:29 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 6 ms / 4,000 ms | 
| コード長 | 789 bytes | 
| コンパイル時間 | 1,913 ms | 
| コンパイル使用メモリ | 171,204 KB | 
| 実行使用メモリ | 6,016 KB | 
| 最終ジャッジ日時 | 2024-12-23 09:46:59 | 
| 合計ジャッジ時間 | 3,156 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 6 | 
| other | AC * 36 | 
ソースコード
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
signed main(){
    ios::sync_with_stdio(false);
	cin.tie(0);
 
    int n,m;
    cin>>n>>m;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    vector<vector<int>> v(111111);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;
        a--,b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    bool pos=false;
    for(int i=0;i<1111;i++){
        for(auto j:v[i]){
            for(auto k:v[j]){
                if(k==i) continue;
                if(a[i]==a[k]) continue;
                if(a[i]<a[j] && a[j]>a[k]) pos=true;
                if(a[i]>a[j] && a[k]>a[j]) pos=true;
            }
        }
    }
    if(pos){
        cout<<"YES"<<endl;
    }
    else cout<<"NO"<<endl;
}
            
            
            
        