結果

問題 No.2432 Flip and Move
ユーザー shobonvipshobonvip
提出日時 2023-08-18 23:23:49
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,701 bytes
コンパイル時間 5,386 ms
コンパイル使用メモリ 289,456 KB
実行使用メモリ 176,744 KB
最終ジャッジ日時 2024-05-06 06:07:50
合計ジャッジ時間 9,014 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,624 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;

//* ATCODER
#include<atcoder/all>
using namespace atcoder;
typedef modint998244353 mint;
//*/

/* BOOST MULTIPRECISION
#include<boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
//*/

typedef long long ll;

#define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
#define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--)

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

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

template <typename T> T max(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]);
	return ret;
}

template <typename T> T min(vector<T> &a){
	assert(!a.empty());
	T ret = a[0];
	for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]);
	return ret;
}

template <typename T> T sum(vector<T> &a){
	T ret = 0;
	for (int i=0; i<(int)a.size(); i++) ret += a[i];
	return ret;
}

// JOUTAI ... (ICHI, HOUKOU)
// DOUBLING

int main(){
	int h, w; cin >> h >> w;
	ll k; cin >> k;
	vector go(4, vector(h, vector<tuple<int,int,int>>(w)));
	rep(i,0,4){
		rep(j,0,h){
			rep(l,0,w){
				int x = j, y = l, t = i;
				if (i&1){
					x = x-1;
				}else{
					x = x+1;
				}
				if (!(0 <= x && x < h)){
					t ^= 1;
					x = min(x, h-1);
					x = max(x, 0);
				}
				if (i&2){
					y = y-1;
				}else{
					y = y+1;
				}
				if (!(0 <= y && y < w)){
					t ^= 2;
					y = min(y, w-1);
					y = max(y, 0);
				}

				go[i][j][l] = make_tuple(t, x, y);
			}
		}
	}
	vector dp(4, vector(h, vector<int>(w)));
	dp[0][0][0] = 1;
	//return 0;
	vector pp(4, vector(h, vector<int>(w)));
	pp[0][0][0] = 1;
	//return 0;
	k--;
	rep(num,0,60){
		if (k >> num & 1){
			vector pr(4, vector(h, vector<int>(w)));
			rep(i,0,4){
				rep(j,0,h){
					rep(l,0,w){
						auto [x, y, z] = go[i][j][l];
						pr[x][y][z] ^= pp[i][j][l];
					}
				}
			}
			rep(i,0,4){
				rep(j,0,h){
					rep(l,0,w){
						pr[i][j][l] ^= dp[i][j][l];
					}
				}
			}
			pp = pr;
		}
		
		vector ndp = dp;
		rep(i,0,4){
			rep(j,0,h){
				rep(l,0,w){
					auto [x, y, z] = go[i][j][l];
					ndp[x][y][z] ^= dp[i][j][l];
				}
			}
		}
		dp = ndp;

		vector ngo(4, vector(h, vector<tuple<int,int,int>>(w)));
		rep(i,0,4){
			rep(j,0,h){
				rep(l,0,w){
					auto [x1, y1, z1] = go[i][j][l];
					auto [x2, y2, z2] = go[x1][y1][z1];
					ngo[i][j][l] = tuple(x2, y2, z2);
				}
			}
		}
		go = ngo;
	}
	//return 0;
	rep(i,0,h){
		rep(j,0,w){
			int g = 0;
			rep(l,0,4){
				g ^= pp[l][i][j];
			}
			if (g == 0){
				cout << '.';
			}else{
				cout << '#';
			}
		}
		cout << endl;
	}
}

0