結果

問題 No.408 五輪ピック
ユーザー finefine
提出日時 2016-08-05 23:49:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 832 bytes
コンパイル時間 2,407 ms
コンパイル使用メモリ 170,240 KB
実行使用メモリ 53,120 KB
最終ジャッジ日時 2024-04-24 19:54:41
合計ジャッジ時間 26,509 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 2 ms
5,376 KB
testcase_05 AC 17 ms
5,376 KB
testcase_06 AC 2,548 ms
49,920 KB
testcase_07 AC 1,663 ms
33,792 KB
testcase_08 AC 54 ms
5,376 KB
testcase_09 AC 230 ms
7,552 KB
testcase_10 WA -
testcase_11 AC 806 ms
18,304 KB
testcase_12 AC 1,255 ms
26,496 KB
testcase_13 AC 22 ms
5,376 KB
testcase_14 WA -
testcase_15 AC 15 ms
5,376 KB
testcase_16 AC 41 ms
5,376 KB
testcase_17 AC 153 ms
6,272 KB
testcase_18 AC 444 ms
11,560 KB
testcase_19 AC 1,066 ms
23,040 KB
testcase_20 AC 925 ms
20,480 KB
testcase_21 AC 291 ms
8,832 KB
testcase_22 AC 2,609 ms
50,560 KB
testcase_23 AC 2,723 ms
53,120 KB
testcase_24 WA -
testcase_25 AC 11 ms
5,376 KB
testcase_26 AC 2,715 ms
53,120 KB
testcase_27 AC 11 ms
5,376 KB
testcase_28 AC 676 ms
16,000 KB
testcase_29 AC 670 ms
16,000 KB
testcase_30 WA -
testcase_31 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

using namespace std;

typedef vector<bool> vec;
typedef vector<vec> mat;

mat A;
vec x;

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    A = mat(n, vec(n, false));
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        A[a][b] = true;
        A[b][a] = true;
    }
    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]) cout << "YES\n";
    else cout << "NO\n";
    return 0;
}
0