結果

問題 No.1400 すごろくで世界旅行
ユーザー yosswi414yosswi414
提出日時 2020-12-09 13:13:10
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,300 bytes
コンパイル時間 1,855 ms
コンパイル使用メモリ 207,404 KB
実行使用メモリ 12,992 KB
最終ジャッジ日時 2023-08-19 02:51:38
合計ジャッジ時間 7,234 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

int main() {
    int v, d;
    cin >> v >> d;
    using bs = bitset<1000>;
    vector<bs> E(v);
    for (auto& i : E) {
        string str;
        cin >> str;
        reverse(str.begin(), str.end());
        i = bs(str);
    }
    const int pwrdp = 20; // 2^20 > 640000 > 2^19
    vector<vector<bs>> dp(pwrdp, vector<bs>(v));
    dp[0] = E;
    for (int i = 1; i < pwrdp; ++i) {
        for (int j = 0; j < v;++j){
            for (int k = dp[i - 1][j]._Find_first(); k < v; k = dp[i - 1][j]._Find_next(k)) {
                dp[i][j] |= dp[i - 1][k];
            }
        }
    }

    vector<bs> Rchbl(v), x, emp(v);
    bool rempty = true;
    for (int di = 0, dd = d; dd > 0; ++di, dd /= 2) {
        if(dd&1){
            if(rempty){
                Rchbl = dp[di];
                rempty = false;
            } else {
                x = emp;
                for (int i = 0; i < v; ++i) {
                    for (int j = Rchbl[i]._Find_first(); j < v; j = Rchbl[i]._Find_next(j)) {
                        x[i] |= dp[di][j];
                    }
                }
                Rchbl = x;
            }
        }
    }
    for (int i = 0; i < v;++i)
        if (Rchbl[i].count() < v) return cout << "No" << endl, 0;
    cout << "Yes" << endl;
}
0