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