結果
| 問題 |
No.629 グラフの中に眠る門松列
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-05-16 16:57:17 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 890 bytes |
| コンパイル時間 | 1,894 ms |
| コンパイル使用メモリ | 200,044 KB |
| 最終ジャッジ日時 | 2025-01-21 13:14:03 |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 5 WA * 1 |
| other | AC * 28 WA * 8 |
ソースコード
#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[i]);
}
if (L == 2 || R == 2)
{
cout << "YES" << '\n';
return 0;
}
}
}
cout << "NO" << '\n';
return 0;
}