結果

問題 No.408 五輪ピック
ユーザー finefine
提出日時 2016-08-05 23:25:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 812 bytes
コンパイル時間 1,815 ms
コンパイル使用メモリ 168,056 KB
実行使用メモリ 815,616 KB
最終ジャッジ日時 2024-04-24 18:16:15
合計ジャッジ時間 3,488 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 2 ms
5,376 KB
testcase_03 AC 1 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 14 ms
6,400 KB
testcase_06 MLE -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;

mat A;
vec x;

vec mul(const mat& A, const vec& x) {
    int s = x.size();
    vec ret(s, 0);
    for (int i = 0; i < s; i++) {
        for (int j = 0; j < s; j++) {
            ret[i] += A[i][j] * x[j];
        }
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    A = mat(n, vec(n, 0));
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        A[a][b] = 1;
        A[b][a] = 1;
    }
    x = vec(n);
    for (int i = 0; i < n; i++) x[i] = A[0][i];
    for (int i = 0; i < 4; i++) {
        x = mul(A, x);
    }
    if (x[0] == 0) cout << "NO\n";
    else cout << "YES\n";
    return 0;
}
0