結果
問題 | No.629 グラフの中に眠る門松列 |
ユーザー |
![]() |
提出日時 | 2019-06-25 21:09:17 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 4,000 ms |
コード長 | 1,355 bytes |
コンパイル時間 | 1,892 ms |
コンパイル使用メモリ | 175,276 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-23 07:44:57 |
合計ジャッジ時間 | 2,863 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 36 |
ソースコード
#include "bits/stdc++.h" #define REP(i, n, N) for(ll i=(n); i<(N); i++) #define RREP(i, n, N) for(ll i=(N-1); i>=n; i--) #define SPACEREP(lst,itr) for(auto itr=lst.begin(); itr!=lst.end();++itr){cout<<*itr<<(++itr!=anslist.end()?" ":"\n");itr--;} #define CK(n, a, b) ((a)<=(n)&&(n)<(b)) #define ALL(v) (v).begin(),(v).end() #define MCP(a, b) memcpy(b,a,sizeof(b)) #define p(s) cout<<(s)<<endl #define p2(a, b) cout<<(a)<<" "<<(b)<<endl #define v2(T) vector<vector<T>> typedef long long ll; using namespace std; const ll mod = 1e9 + 7; const ll inf = 1e18; int main(){ int N,M; cin >> N >> M; vector<vector<pair<int,int>>> edge(N+1); vector<int> value(N+1); int u,v; REP(i,1,N+1){ cin >> value[i]; } REP(i,1,M+1){ cin >> u >> v; if(value[u]-value[v]==0)continue; edge[u].push_back(make_pair(v,value[u]-value[v])); edge[v].push_back(make_pair(u,value[v]-value[u])); } bool flag=false; REP(i,1,N+1){ for(auto x : edge[i]){ for(auto y : edge[i]){ if(x.first==y.first)continue; if(x.second==y.second)continue; if(x.second<0 && y.second>0)continue; if(x.second>0 && y.second<0)continue; flag=true; } } } cout << (flag ? "YES" : "NO") << endl; }