結果

問題 No.2432 Flip and Move
ユーザー aradarad
提出日時 2023-08-19 15:35:57
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,718 bytes
コンパイル時間 4,723 ms
コンパイル使用メモリ 270,216 KB
実行使用メモリ 144,916 KB
最終ジャッジ日時 2024-05-06 22:41:05
合計ジャッジ時間 10,612 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
13,884 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 1,458 ms
144,916 KB
testcase_03 TLE -
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;
#include <atcoder/all>
using namespace atcoder;
using ll = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using P = pair<ll,ll>;
using VP = vector<P>;
#define rep(i, n) for (ll i = 0; i < ll(n); i++)
#define out(x) cout << x << endl
#define dout(x) cout << fixed << setprecision(10) << x << endl
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)(x.size())
#define re0 return 0
#define pcnt __builtin_popcountll
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
constexpr int inf = 1e9;
constexpr ll INF = 1e18;
//using mint = modint1000000007;
using mint = modint998244353;
int di[4] = {1,0,-1,0};
int dj[4] = {0,1,0,-1};

int main(){
    ll h,w,k;
    cin >> h >> w >> k;
    VS s(h);
    rep(i,h)rep(j,w) s[i].push_back('.');
    vector<vector<vector<ll>>> memo(h,vector<vector<ll>>(w,vector<ll>(4,-1)));
    memo[0][0][0] = 0;
    bool flag = false;
    ll i = 0,j = 0,state = 0;
    ll cnt = 0;
    while(cnt < k){
        if(s[i][j] == '.') s[i][j] = '#';
        else s[i][j] = '.';
        ll pi = i,pj = j,pstate = state;
        //jouge
        if(state>>1&1){
            //ue
            ll ni = i-1;
            ll nj = j;
            if(ni < 0 || nj < 0 || ni >= h || nj >= w){
                state ^= 1<<1;
            } else {
                i = ni;
                j = nj;
            }
        } else {
            //shita
            ll ni = i+1;
            ll nj = j;
            if(ni < 0 || nj < 0 || ni >= h || nj >= w){
                state ^= 1<<1;
            } else {
                i = ni;
                j = nj;
            }
        }
        if(state&1){
            //hidari
            ll ni = i;
            ll nj = j-1;
            if(ni < 0 || nj < 0 || ni >= h || nj >= w){
                state ^= 1;
            } else {
                i = ni;
                j = nj;
            }
        } else {
            //migi
            ll ni = i;
            ll nj = j+1;
            if(ni < 0 || nj < 0 || ni >= h || nj >= w){
                state ^= 1;
            } else {
                i = ni;
                j = nj;
            }
        }
        if(memo[i][j][state] == -1 || flag){
            memo[i][j][state] = memo[pi][pj][pstate]+1;
        } else {
            flag = true;
            cnt %= (memo[pi][pj][pstate]-memo[i][j][state]+1)*2;
        }
        cnt++;
    }
    rep(i,h) out(s[i]);
}
0