結果

問題 No.1400 すごろくで世界旅行
ユーザー N_N_MochiN_N_Mochi
提出日時 2021-02-19 23:46:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,265 bytes
コンパイル時間 2,401 ms
コンパイル使用メモリ 191,060 KB
実行使用メモリ 70,436 KB
最終ジャッジ日時 2023-10-17 00:10:10
合計ジャッジ時間 9,745 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

//#define _GLIBCXX_DEBUG
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
//#include <atcoder/all>
using ll = long long;
using ld = long double;
#define FOR(i, a, b) for(ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(ll i = (ll)(a - 1); i >= (ll)(b); i--)
#define rrep(i, a) rFOR(i, a, 0)
#define all(c) begin(c),end(c)
using namespace std;
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<P> vP;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
const ld PI = acos(-1);
const ll INF = 1e18;
struct edge{ll to, cost;};

template <typename T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
bool chmin(T &a, const T &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

/*const long long MXV = 2000;
vl G[MXV];
vector<vvl> d(MXV,vvl(MXV, vl(2,INF)));



void dijkstra(int i,int s){
    queue<pair<P,int>> pq;
    d[i][s][0] = 0;
    pair<P,int> q;
    q.first=P(0,s);q.second=0;
    pq.push(q);
    while(pq.size()){
        pair<P,int> p = pq.front();
        pq.pop();
        int V = p.first.second;
        int sig=p.second;
        rep(k,G[V].size()){
            int to = G[V][k];
            if(d[i][to][1^sig] > d[i][V][sig] + 1){
                d[i][to][1^sig] = d[i][V][sig] + 1;
                pair<P,int> neko;
                neko.first=P(d[i][to][1^sig],to);
                neko.second=1^sig;
                pq.push(neko);
            }
        }
    }
}
*/
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int V;
    ll D;
    cin >> V >> D;
    vector<vector<int>> A(2*V,vector<int>(2*V,1e9));
    rep(i,V){
        string S;
        cin >> S;
        rep(j,V){
            if(S[j]=='1') A[V+i][j]=A[i][V+j]=A[j][V+i]=A[V+j][i]=1;
        }
    }
    rep(k,2*V){
        rep(i,2*V){
            rep(j,2*V){
                chmin(A[i][j],A[i][k]+A[k][j]);
            }
        }
    }
    int par=D%2;
    rep(i,V) rep(j,V){
        if(A[i][par*V+j]>=D){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}
0