結果
| 問題 |
No.2432 Flip and Move
|
| コンテスト | |
| ユーザー |
shobonvip
|
| 提出日時 | 2023-08-18 23:25:30 |
| 言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 2,793 bytes |
| コンパイル時間 | 25,326 ms |
| コンパイル使用メモリ | 363,036 KB |
| 最終ジャッジ日時 | 2025-02-16 10:51:05 |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 2 TLE * 1 -- * 33 |
ソースコード
#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 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 << '\n';
}
}
shobonvip