結果
問題 | No.629 グラフの中に眠る門松列 |
ユーザー |
![]() |
提出日時 | 2018-01-18 14:26:34 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 65 ms / 4,000 ms |
コード長 | 624 bytes |
コンパイル時間 | 2,165 ms |
コンパイル使用メモリ | 197,128 KB |
最終ジャッジ日時 | 2025-01-05 07:40:50 |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 6 |
other | AC * 36 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int n, m; cin>>n>>m; vector<int> a(n); for(auto& e: a) cin>>e; vector<pair<int, int>> edges; while (m--) { int u, v; cin>>u>>v; edges.emplace_back(--u, --v); edges.emplace_back(v, u); } auto is_kadomatsu=[&](int i, int j, int k) { return (a[i]<a[j] and a[j]>a[k] or a[i]>a[j] and a[j]<a[k]) and a[i]!=a[k]; }; for(auto& [u, v]: edges) { for(auto& [x, y]: edges) { if (v==x and is_kadomatsu(u, v, y)) return cout<<"YES"<<endl, 0; } } cout<<"NO"<<endl; }