結果
| 問題 |
No.629 グラフの中に眠る門松列
|
| コンテスト | |
| ユーザー |
dnish
|
| 提出日時 | 2018-06-16 10:14:36 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,016 bytes |
| コンパイル時間 | 1,617 ms |
| コンパイル使用メモリ | 171,240 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-06-30 16:09:44 |
| 合計ジャッジ時間 | 2,855 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 21 WA * 15 |
ソースコード
#include "bits/stdc++.h"
#define REP(i,n,N) for(int i=(n); i<(N); i++)
#define RREP(i,n,N) for(int i=(N-1); i>=n; i--)
#define CK(n,a,b) (a)<=(n)&&(n)<(b)
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
typedef long long ll;
using namespace std;
const int inf =1e9+7;
int main(){
int N,M;
while(cin>>N>>M){
int a[1010];
vector<int> edge[1010];
REP(i,0,N){
cin>>a[i];
}
REP(i,0,M){
int u,v;
cin>>u>>v;
u--;v--;
edge[u].push_back(v);
//edge[v].push_back(u);
}
bool ok=false;
REP(i,0,N){
for(auto e:edge[i]){
if(a[i]==a[e]) continue;
for(auto v:edge[e]){
if(a[e]==a[v]||a[v]==a[i]) continue;
if((a[i]<a[e]&&a[e]<a[i])||(a[i]>a[e]&&a[e]>a[i])) continue;
ok=true;
}
}
}
p(ok?"YES":"NO");
}
return 0;
}
dnish