結果

問題 No.2432 Flip and Move
ユーザー shobonvipshobonvip
提出日時 2023-08-18 23:29:34
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,860 ms / 2,000 ms
コード長 2,282 bytes
コンパイル時間 6,684 ms
コンパイル使用メモリ 301,608 KB
実行使用メモリ 81,620 KB
最終ジャッジ日時 2024-05-06 06:18:16
合計ジャッジ時間 16,162 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,816 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 1,552 ms
81,620 KB
testcase_03 AC 1,536 ms
81,504 KB
testcase_04 AC 1,591 ms
81,436 KB
testcase_05 AC 1,860 ms
81,456 KB
testcase_06 AC 825 ms
44,208 KB
testcase_07 AC 1,029 ms
54,156 KB
testcase_08 AC 1,088 ms
58,364 KB
testcase_09 AC 1,683 ms
78,844 KB
testcase_10 AC 1,025 ms
52,760 KB
testcase_11 AC 1,177 ms
59,884 KB
testcase_12 AC 906 ms
45,452 KB
testcase_13 AC 1,196 ms
59,924 KB
testcase_14 AC 336 ms
20,848 KB
testcase_15 AC 1,382 ms
67,736 KB
testcase_16 AC 633 ms
34,384 KB
testcase_17 AC 1,483 ms
71,020 KB
testcase_18 AC 398 ms
22,344 KB
testcase_19 AC 1,212 ms
55,420 KB
testcase_20 AC 1,730 ms
77,968 KB
testcase_21 AC 1,201 ms
54,468 KB
testcase_22 AC 1,308 ms
62,576 KB
testcase_23 AC 317 ms
18,088 KB
testcase_24 AC 1,531 ms
68,224 KB
testcase_25 AC 1,036 ms
50,808 KB
testcase_26 AC 1,361 ms
62,156 KB
testcase_27 AC 101 ms
7,592 KB
testcase_28 AC 35 ms
6,940 KB
testcase_29 AC 1,010 ms
53,128 KB
testcase_30 AC 1,573 ms
73,660 KB
testcase_31 AC 1,235 ms
59,460 KB
testcase_32 AC 119 ms
8,448 KB
testcase_33 AC 1,529 ms
72,044 KB
testcase_34 AC 744 ms
39,120 KB
testcase_35 AC 1,124 ms
52,032 KB
testcase_36 AC 1 ms
6,944 KB
testcase_37 AC 2 ms
6,940 KB
testcase_38 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#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<int> go(4*h*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*h*w+j*w+l] = t*h*w+x*w+y;
			}
		}
	}
	vector<int> dp(4*h*w);
	dp[0] = 1;
	//return 0;
	vector<int> pp(4*h*w);
	pp[0] = 1;
	//return 0;
	k--;
	rep(num,0,60){
		if (k >> num & 1){
			vector<int> pr(4*h*w);
			rep(i,0,4*h*w){
				pr[go[i]] ^= pp[i];
				pr[i] ^= dp[i];
			}
			pp = pr;
		}
		
		vector<int> ndp = dp;
		rep(i,0,4*h*w){
			ndp[go[i]] ^= dp[i];
		}
		dp = ndp;

		vector<int> ngo(4*h*w);
		rep(i,0,4*h*w){
			ngo[i] = go[go[i]];
		}
		go = ngo;
	}
	//return 0;
	rep(i,0,h){
		rep(j,0,w){
			int g = 0;
			rep(l,0,4){
				g ^= pp[l*h*w+i*w+j];
			}
			if (g == 0){
				cout << '.';
			}else{
				cout << '#';
			}
		}
		cout << '\n';
	}
}

0