結果

問題 No.1400 すごろくで世界旅行
ユーザー KudeKude
提出日時 2021-02-20 01:02:26
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,137 bytes
コンパイル時間 2,655 ms
コンパイル使用メモリ 221,132 KB
実行使用メモリ 5,668 KB
最終ジャッジ日時 2023-10-17 05:30:26
合計ジャッジ時間 14,611 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
5,532 KB
testcase_01 AC 103 ms
5,532 KB
testcase_02 AC 529 ms
5,532 KB
testcase_03 AC 256 ms
5,536 KB
testcase_04 AC 140 ms
5,536 KB
testcase_05 AC 274 ms
5,536 KB
testcase_06 AC 277 ms
5,536 KB
testcase_07 AC 311 ms
5,536 KB
testcase_08 AC 259 ms
5,536 KB
testcase_09 AC 327 ms
5,536 KB
testcase_10 AC 262 ms
5,536 KB
testcase_11 AC 387 ms
5,536 KB
testcase_12 AC 320 ms
5,536 KB
testcase_13 AC 1,750 ms
5,536 KB
testcase_14 AC 1,754 ms
5,536 KB
testcase_15 WA -
testcase_16 AC 81 ms
5,536 KB
testcase_17 AC 81 ms
5,536 KB
testcase_18 WA -
testcase_19 AC 41 ms
5,532 KB
testcase_20 AC 42 ms
5,532 KB
権限があれば一括ダウンロードができます

ソースコード

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(b, 32) {
                ull z = 0;
                int j = b << 6;
                rep(bx, 64) {
                    ull x = 0;
                    rep(k, 32) x |= tmp[i][k] & et[j][k];
                    z |= bool(x) << bx;
                    j++;
                }
                now[i][b] = z;
            }
        }

        rep(i, 2000) rep(j, 32) tmp[i][j] = e[i][j], e[i][j] = 0;
        rep(i, 2000) rep(b, 32) {
            ull z = 0;
            int j = b << 6;
            rep(bx, 64) {
                ull x = 0;
                rep(k, 32) x |= tmp[i][k] & et[j][k];
                z |= bool(x) << bx;
                j++;
            }
            e[i][b] = z;
        }
        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