結果

問題 No.1400 すごろくで世界旅行
ユーザー 👑 kmjpkmjp
提出日時 2021-02-19 22:42:21
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 591 ms / 3,153 ms
コード長 1,437 bytes
コンパイル時間 3,997 ms
コンパイル使用メモリ 201,084 KB
実行使用メモリ 35,628 KB
最終ジャッジ日時 2023-10-15 03:36:17
合計ジャッジ時間 6,633 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,372 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,372 KB
testcase_03 AC 3 ms
4,372 KB
testcase_04 AC 2 ms
4,372 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 9 ms
6,356 KB
testcase_07 AC 13 ms
8,460 KB
testcase_08 AC 3 ms
4,380 KB
testcase_09 AC 3 ms
4,376 KB
testcase_10 AC 5 ms
6,444 KB
testcase_11 AC 3 ms
4,372 KB
testcase_12 AC 41 ms
12,816 KB
testcase_13 AC 571 ms
35,628 KB
testcase_14 AC 583 ms
35,604 KB
testcase_15 AC 474 ms
35,496 KB
testcase_16 AC 566 ms
35,496 KB
testcase_17 AC 591 ms
35,444 KB
testcase_18 AC 466 ms
35,520 KB
testcase_19 AC 2 ms
4,376 KB
testcase_20 AC 1 ms
4,372 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define FORR2(x,y,arr) for(auto& [x,y]:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
template<class T> bool chmax(T &a, const T &b) { if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a, const T &b) { if(a>b){a=b;return 1;}return 0;}
//-------------------------------------------------------

int N;
ll T;
string S;
bitset<2040> E[2020];
int D[2020][2020][2];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>T;
	FOR(y,N) {
		cin>>S;
		FOR(x,N) {
			E[y][x]=S[x]=='1';
			D[y][x][0]=D[y][x][1]=101010;
		}
	}
	
	
	FOR(i,N) {
		bitset<2040> B[2],nex[2];
		nex[0][i]=1;
		FOR(j,2*N+1) {
			bitset<2040> diff=B[j&1]^nex[j&1];
			while(diff._Find_first()<N) {
				x=diff._Find_first();
				diff[x]=diff[x]^1;
				B[j&1][x]=1;
				D[i][x][j&1]=j;
				nex[(j&1)^1] |= E[x];
			}
		}
	}
	
	FOR(y,N) FOR(x,N) {
		if(D[y][x][T%2]>T) return _P("No\n");
		if(D[y][x][T%2]==101010) return _P("No\n");
	}
	cout<<"Yes"<<endl;
	
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}
0