結果

問題 No.1400 すごろくで世界旅行
ユーザー kotatsugamekotatsugame
提出日時 2021-02-25 00:11:46
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 714 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 69,376 KB
実行使用メモリ 9,764 KB
最終ジャッジ日時 2023-10-25 05:38:37
合計ジャッジ時間 8,405 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,696 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 4 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 3 ms
4,348 KB
testcase_06 AC 13 ms
4,348 KB
testcase_07 AC 25 ms
4,348 KB
testcase_08 AC 5 ms
4,348 KB
testcase_09 AC 5 ms
4,348 KB
testcase_10 AC 8 ms
4,348 KB
testcase_11 AC 4 ms
4,348 KB
testcase_12 AC 85 ms
4,348 KB
testcase_13 TLE -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<bitset>
using namespace std;
int V;
long D;
bitset<2000>E[2000],ET[2000],A[2000],T[2000];
main()
{
	cin>>V>>D;
	for(int i=0;i<V;i++)
	{
		string s;cin>>s;
		for(int j=0;j<V;j++)E[i][j]=s[j]-'0';
		A[i][i]=1;
	}
	while(D)
	{
		for(int i=0;i<V;i++)for(int j=0;j<V;j++)ET[j][i]=E[i][j];
		if(D&1)
		{
			for(int i=0;i<V;i++)for(int j=0;j<V;j++)
			{
				T[i][j]=(A[i]&ET[j]).any()?1:0;
			}
			for(int i=0;i<V;i++)A[i]=T[i];
		}
		D>>=1;
		for(int i=0;i<V;i++)for(int j=0;j<V;j++)
		{
			T[i][j]=(E[i]&ET[j]).any()?1:0;
		}
		for(int i=0;i<V;i++)E[i]=T[i];
	}
	for(int i=0;i<V;i++)for(int j=0;j<V;j++)
	{
		if(A[i][j]==0)
		{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
}
0