結果

問題 No.2432 Flip and Move
ユーザー aradarad
提出日時 2023-08-19 15:37:31
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 1,365 ms / 2,000 ms
コード長 2,696 bytes
コンパイル時間 4,045 ms
コンパイル使用メモリ 268,204 KB
実行使用メモリ 144,784 KB
最終ジャッジ日時 2024-05-06 22:43:21
合計ジャッジ時間 22,929 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 212 ms
144,784 KB
testcase_03 AC 1,365 ms
136,064 KB
testcase_04 AC 97 ms
75,520 KB
testcase_05 AC 98 ms
75,648 KB
testcase_06 AC 81 ms
58,684 KB
testcase_07 AC 900 ms
89,344 KB
testcase_08 AC 1,019 ms
96,640 KB
testcase_09 AC 1,338 ms
131,200 KB
testcase_10 AC 139 ms
92,716 KB
testcase_11 AC 176 ms
105,780 KB
testcase_12 AC 118 ms
79,664 KB
testcase_13 AC 133 ms
80,288 KB
testcase_14 AC 333 ms
33,024 KB
testcase_15 AC 1,140 ms
112,704 KB
testcase_16 AC 358 ms
31,872 KB
testcase_17 AC 703 ms
65,152 KB
testcase_18 AC 89 ms
21,120 KB
testcase_19 AC 553 ms
51,968 KB
testcase_20 AC 613 ms
72,320 KB
testcase_21 AC 925 ms
50,688 KB
testcase_22 AC 294 ms
58,240 KB
testcase_23 AC 75 ms
17,536 KB
testcase_24 AC 562 ms
63,104 KB
testcase_25 AC 470 ms
47,360 KB
testcase_26 AC 369 ms
58,240 KB
testcase_27 AC 8 ms
7,168 KB
testcase_28 AC 6 ms
5,376 KB
testcase_29 AC 854 ms
48,896 KB
testcase_30 AC 1,099 ms
68,096 KB
testcase_31 AC 475 ms
54,912 KB
testcase_32 AC 13 ms
7,936 KB
testcase_33 AC 1,162 ms
66,816 KB
testcase_34 AC 410 ms
36,096 KB
testcase_35 AC 236 ms
48,128 KB
testcase_36 AC 2 ms
5,376 KB
testcase_37 AC 2 ms
5,376 KB
testcase_38 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

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;
    while(k > 0){
        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;
            k %= (memo[pi][pj][pstate]-memo[i][j][state]+1)*2;
        }
        k--;
    }
    rep(i,h) out(s[i]);
}
0