結果
| 問題 |
No.629 グラフの中に眠る門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-16 16:58:19 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 4,000 ms |
| コード長 | 890 bytes |
| コンパイル時間 | 2,126 ms |
| コンパイル使用メモリ | 200,284 KB |
| 最終ジャッジ日時 | 2025-01-21 13:14:12 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 6 |
| other | AC * 36 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
int a[1001];
vector <int> adj[1001];
int n, m, u, v;
int main(void)
{
cin.tie(0);
ios::sync_with_stdio(false);
cin >> n >> m;
for (int i = 1; i <= n; i++)
{
cin >> a[i];
}
for (int i = 0; i < m; i++)
{
cin >> u >> v;
adj[u].push_back(v);
adj[v].push_back(u);
}
for (int i = 1; i <= n; i++)
{
int L = 0;
int R = 0;
set <int> S;
for (auto j : adj[i])
{
if (S.find(a[j]) == S.end())
{
if (a[j] > a[i]) R++;
else if (a[j] < a[i]) L++;
S.insert(a[j]);
}
if (L == 2 || R == 2)
{
cout << "YES" << '\n';
return 0;
}
}
}
cout << "NO" << '\n';
return 0;
}