結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 WA -
testcase_14 AC 2 ms
4,380 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
4,380 KB
testcase_21 AC 4 ms
4,404 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 3 ms
4,380 KB
testcase_25 AC 3 ms
4,380 KB
testcase_26 AC 3 ms
4,380 KB
testcase_27 WA -
testcase_28 AC 4 ms
4,604 KB
testcase_29 AC 4 ms
4,400 KB
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 4 ms
4,652 KB
testcase_33 AC 5 ms
4,520 KB
testcase_34 AC 4 ms
4,380 KB
testcase_35 AC 3 ms
4,576 KB
testcase_36 WA -
testcase_37 AC 4 ms
4,380 KB
testcase_38 WA -
testcase_39 WA -
testcase_40 AC 3 ms
4,400 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;
            return 0;
        }
    }
    cout << "NO" << endl;
    return 0;
}
0