結果

問題 No.1400 すごろくで世界旅行
ユーザー KudeKude
提出日時 2021-02-20 00:17:16
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 1,979 bytes
コンパイル時間 3,267 ms
コンパイル使用メモリ 219,516 KB
実行使用メモリ 9,748 KB
最終ジャッジ日時 2023-10-17 02:28:07
合計ジャッジ時間 27,056 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 346 ms
5,628 KB
testcase_01 AC 447 ms
5,628 KB
testcase_02 AC 2,217 ms
5,628 KB
testcase_03 AC 1,132 ms
5,632 KB
testcase_04 AC 612 ms
5,632 KB
testcase_05 AC 1,143 ms
5,632 KB
testcase_06 AC 1,127 ms
5,632 KB
testcase_07 AC 1,303 ms
5,632 KB
testcase_08 AC 1,128 ms
5,632 KB
testcase_09 AC 1,460 ms
5,632 KB
testcase_10 AC 1,125 ms
5,632 KB
testcase_11 AC 1,561 ms
5,632 KB
testcase_12 AC 1,242 ms
5,632 KB
testcase_13 AC 1,324 ms
5,632 KB
testcase_14 AC 1,876 ms
5,632 KB
testcase_15 TLE -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < int(n); ++i)
#define rrep(i,n) for(int i = int(n)-1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
template<class T> void chmax(T& a, const T& b) {a = max(a, b);}
template<class T> void chmin(T& a, const T& b) {a = min(a, b);}
using ll = long long;
using P = pair<int,int>;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using ull = unsigned long long;

ull e[2000][32], et[2000][32], now[2000][32], tmp[2000][32];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int v;
    ull d;
    cin >> v >> d;
    assert(v <= 2000);
    rep(i, v) rep(j, v) {
        char t;
        cin >> t;
        e[i][j >> 6] |= ull(t - '0') << (j & 63);
    }
    rep(i, v) {
        now[i][i >> 6] = 1 << (i & 63);
    }
    while(d) {
        rep(i, 2000) rep(j, 32) et[i][j] = 0;
        rep(i, 2000) rep(j, 2000) {
            et[j][i >> 6] |= (e[i][j >> 6] >> (j & 63) & 1) << (i & 63);
        }
        if (d & 1) {
            rep(i, 2000) rep(j, 32) tmp[i][j] = now[i][j], now[i][j] = 0;
            rep(i, 2000) rep(j, 2000) {
                rep(k, 32) {
                    if (tmp[i][k] & et[j][k]) {
                        now[i][j >> 6] |= 1 << (j & 63);
                        break;
                    }
                }
            }
        }

        rep(i, 2000) rep(j, 32) tmp[i][j] = e[i][j], e[i][j] = 0;
        rep(i, 2000) rep(j, 2000) {
            rep(k, 32) {
                if (tmp[i][k] & et[j][k]) {
                    e[i][j >> 6] |= 1 << (j & 63);
                    break;
                }
            }
        }
        d >>= 1;
    }
    bool ok = true;
    rep(i, v) rep(j, v) if (!(now[i][j >> 6] >> (j & 63) & 1)) ok = false;
    cout << (ok ? "Yes\n" : "No\n");
}
0