結果

問題 No.1400 すごろくで世界旅行
ユーザー chocoruskchocorusk
提出日時 2021-02-19 23:14:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,048 bytes
コンパイル時間 1,280 ms
コンパイル使用メモリ 133,676 KB
実行使用メモリ 34,128 KB
最終ジャッジ日時 2023-10-16 22:56:13
合計ジャッジ時間 6,137 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 7 ms
4,348 KB
testcase_01 AC 20 ms
4,348 KB
testcase_02 AC 6 ms
4,348 KB
testcase_03 AC 12 ms
4,348 KB
testcase_04 AC 25 ms
4,348 KB
testcase_05 AC 16 ms
4,348 KB
testcase_06 AC 12 ms
4,348 KB
testcase_07 AC 13 ms
4,348 KB
testcase_08 AC 12 ms
4,348 KB
testcase_09 AC 11 ms
4,348 KB
testcase_10 AC 12 ms
4,348 KB
testcase_11 AC 11 ms
4,348 KB
testcase_12 AC 17 ms
4,348 KB
testcase_13 AC 67 ms
4,712 KB
testcase_14 AC 143 ms
10,212 KB
testcase_15 RE -
testcase_16 WA -
testcase_17 AC 66 ms
4,712 KB
testcase_18 RE -
testcase_19 AC 6 ms
4,348 KB
testcase_20 AC 6 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>
#define popcount __builtin_popcount
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
bitset<2000> e[61][2000];
bitset<2000> f[2000];
int main()
{
    int v; ll d;
    cin>>v>>d;
    char s[2002];
    for(int i=0; i<v; i++){
        scanf("%s", s);
        for(int j=0; j<v; j++){
            e[0][i][j]=s[j]-'0';
        }
    }
    for(int i=0; i<61; i++){
        for(int j=0; j<2000; j++){
            for(int k=0; k<2000; k++){
                if(e[i][j][k]){
                    e[i+1][j]|=e[i][k];
                }
            }
        }
        bool ok=1;
        for(int j=0; j<v; j++){
            if(e[i+1][j].count()<v){
                ok=0;break;
            }
        }
        if(ok){
            if((1ll<<i)<=d){
                cout<<"Yes"<<endl;
                return 0;
            }
            for(int p=0; p<i; p++){
                if(d&(1ll<<p)){
                    bitset<2000> nf[2000];
                    for(int j=0; j<2000; j++){
                        for(int k=0; k<2000; k++){
                            if(f[j][k]){
                                nf[j]|=e[p][k];
                            }
                        }
                    }
                    for(int j=0; j<2000; j++) f[j]=nf[j];
                }
            }
            for(int j=0; j<v; j++){
                if(f[j].count()<v){
                    cout<<"No"<<endl;
                    return 0;
                }
            }
            cout<<"Yes"<<endl;
            return 0;
        }
        if((1ll<<i)>=d) break;
    }
    cout<<"No"<<endl;
    return 0;
}
0