結果

問題 No.1400 すごろくで世界旅行
ユーザー KudeKude
提出日時 2021-02-20 00:45:32
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2,433 ms / 3,153 ms
コード長 2,305 bytes
コンパイル時間 3,239 ms
コンパイル使用メモリ 220,768 KB
実行使用メモリ 5,592 KB
最終ジャッジ日時 2023-10-17 04:19:41
合計ジャッジ時間 19,978 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
5,588 KB
testcase_01 AC 140 ms
5,588 KB
testcase_02 AC 722 ms
5,588 KB
testcase_03 AC 361 ms
5,592 KB
testcase_04 AC 194 ms
5,592 KB
testcase_05 AC 376 ms
5,592 KB
testcase_06 AC 360 ms
5,592 KB
testcase_07 AC 423 ms
5,592 KB
testcase_08 AC 363 ms
5,592 KB
testcase_09 AC 458 ms
5,592 KB
testcase_10 AC 359 ms
5,592 KB
testcase_11 AC 495 ms
5,592 KB
testcase_12 AC 418 ms
5,592 KB
testcase_13 AC 2,426 ms
5,592 KB
testcase_14 AC 2,423 ms
5,592 KB
testcase_15 AC 2,432 ms
5,592 KB
testcase_16 AC 107 ms
5,592 KB
testcase_17 AC 108 ms
5,592 KB
testcase_18 AC 2,433 ms
5,592 KB
testcase_19 AC 57 ms
5,588 KB
testcase_20 AC 57 ms
5,588 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(j, 2000) {
                /*
                rep(k, 32) {
                    if (tmp[i][k] & et[j][k]) {
                        now[i][j >> 6] |= 1 << (j & 63);
                        break;
                    }
                }
                */
                ull x = 0;
                rep(k, 32) x |= tmp[i][k] & et[j][k];
                now[i][j >> 6] |= bool(x) << (j & 63);
            }
        }

        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;
                }
            }
            */
            ull x = 0;
            rep(k, 32) x |= tmp[i][k] & et[j][k];
            e[i][j >> 6] |= bool(x) << (j & 63);
        }
        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