結果

問題 No.1400 すごろくで世界旅行
ユーザー yosswi414yosswi414
提出日時 2019-12-31 07:12:51
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,316 bytes
コンパイル時間 1,630 ms
コンパイル使用メモリ 170,744 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-08-19 02:49:07
合計ジャッジ時間 3,133 ms
ジャッジサーバーID
(参考情報)
judge10 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 WA -
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 WA -
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 4 ms
4,376 KB
testcase_07 AC 5 ms
4,380 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 11 ms
4,380 KB
testcase_13 WA -
testcase_14 WA -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 WA -
testcase_19 AC 1 ms
4,376 KB
testcase_20 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using pi = pair<int, int>;
using bs = bitset<1000>;

signed main() {
    int v, d;
    cin >> v >> d;
    vector<bs> G(v);
    for (int i = 0; i < v; ++i) {
        string s;
        cin >> s;
        for (int j = 0; j < v; ++j)
            if (s[j] == '1') G[i].set(j);
    }

    bool valid = true;
    
    for (int src = 0; valid && src < v; ++src) {
        bs eprev, oprev, empbs, pos, prev, next;
        
        bool isdegz = true;
        for (int i = 0; isdegz&&i < v;++i)
            if (G[src][i]) isdegz = false;
        if (isdegz) {
            valid = false;
            break;
        }
        pos.set(src);
        prev.set(src);
        for (int mv = 0; mv < d && pos.count() > 0;) {
            for (int i = 0; i < v;++i)
                if (pos[i]) next |= G[i];
            pos = next & ~oprev;
            oprev |= next;
            next = empbs;
            ++mv;
            if (mv >= d) break;
            for (int i = 0; i < v; ++i)
                if (pos[i]) next |= G[i];
            pos = next & ~eprev;
            eprev |= next;
            next = empbs;
            ++mv;
            if (mv >= d) break;
        }
        if((d%2 ? oprev.count() : eprev.count()) < v) valid = false;
    }
    cout << (valid ? "Yes" : ":(") << endl;
}
0