結果
| 問題 | No.1400 すごろくで世界旅行 | 
| コンテスト | |
| ユーザー |  N_N_Mochi | 
| 提出日時 | 2021-02-19 23:00:52 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                MLE
                                 
                             | 
| 実行時間 | - | 
| コード長 | 2,587 bytes | 
| コンパイル時間 | 2,020 ms | 
| コンパイル使用メモリ | 184,828 KB | 
| 実行使用メモリ | 456,704 KB | 
| 最終ジャッジ日時 | 2024-09-16 21:48:31 | 
| 合計ジャッジ時間 | 14,300 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge6 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 MLE * 1 | 
| other | AC * 14 WA * 1 TLE * 1 -- * 2 | 
ソースコード
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
//#include <atcoder/all>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using ll = long long;
using ld = long double;
#define FOR(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) FOR(i, 0, n)
#define rFOR(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rrep(i, a) rFOR(i, a, 0)
#define all(c) begin(c),end(c)
using namespace std;
typedef pair<int,int> 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 int INF = 1e9;
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 int MXV = 2000;
vector<int> G[MXV];
vector<vector<vector<int>>> d(MXV,vector<vector<int>>(MXV, vector<int>(2,INF)));
//bfsにかえる(dijkstraでいいじゃん)
//なんで?笑
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] == INF){
                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);
    ll V,D;
    cin >> V >> D;
    vector<string> A(V);
    bool ok=true,ng=true;
    rep(i,V){
        cin >> A[i];
        rep(j,V){
            if(A[i][j]=='0') ok=false;
            else ng=false;
        }
    }
    rep(i,V){
        rep(j,V){
            if(A[i][j]=='1'){
                G[i].push_back(j);
            }
        }
    }
    if(ok){
        cout << "Yes" << endl;
        return 0;
    }
    if(ng){
        cout << "No" << endl;
        return 0;
    }
    if(D==1){
        cout << "No" << endl;
        return 0;
    }
    ll parity=D%2;
    rep(i,V){
        dijkstra(i,i);
        rep(j,V){
            if(d[i][j][parity]>D){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}
            
            
            
        