結果

問題 No.629 グラフの中に眠る門松列
ユーザー 🍮かんプリン🍮かんプリン
提出日時 2019-03-18 10:58:08
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,033 bytes
コンパイル時間 497 ms
コンパイル使用メモリ 65,256 KB
実行使用メモリ 4,536 KB
最終ジャッジ日時 2023-09-25 01:21:24
合計ジャッジ時間 3,062 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 1 ms
4,376 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 1 ms
4,376 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 4 ms
4,420 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 3 ms
4,376 KB
testcase_26 AC 3 ms
4,376 KB
testcase_27 WA -
testcase_28 AC 3 ms
4,428 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 5 ms
4,376 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 4 ms
4,376 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 4 ms
4,376 KB
testcase_41 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <math.h>

using ll = long long;
using namespace std;

const int MOD = 1e9+7;
bool graph[1010][1010];
int v_size[1010];
int N, M;

// 頂点vから始まる門松パスが存在するか
bool kado(int v) {
    for(int i = 0; i < N; i++)
    {
        if (graph[v][i] && v_size[i] > v_size[v]) {
            for(int j = 0; j < N; j++)
            {
                if (v_size[j] != v_size[v] && graph[i][j] && v_size[i] > v_size[j]) {
                    return true;
                }
            }
        }
    }
    return false;
}

int main() {
    int u, v;
    cin >> N >> M;
    for(int i = 0; i < N; i++)
    {
        cin >> v_size[i];
    }
    for(int i = 0; i < M; i++)
    {
        cin >> u >> v;
        u--; v--;
        graph[u][v] = graph[v][u] = true;
    }
    for(int i = 0; i < N; i++)
    {
        if (kado(i)) {
            cout << "YES" << endl;
            break;
        }
    }
    cout << "NO" << endl;
    return 0;
}
0