結果

問題 No.2432 Flip and Move
ユーザー milanis48663220milanis48663220
提出日時 2023-08-18 23:21:24
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 3,678 bytes
コンパイル時間 2,240 ms
コンパイル使用メモリ 144,408 KB
実行使用メモリ 268,732 KB
最終ジャッジ日時 2023-08-18 23:21:34
合計ジャッジ時間 8,996 ms
ジャッジサーバーID
(参考情報)
judge15 / judge10
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cmath>
#include <numeric>
#include <functional>
#include <cassert>

#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;
#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;

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; }

using namespace std;
typedef long long ll;

template<typename T>
vector<vector<T>> vec2d(int n, int m, T v){
    return vector<vector<T>>(n, vector<T>(m, v));
}

template<typename T>
vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){
    return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));
}

template<typename T>
void print_vector(vector<T> v, char delimiter=' '){
    if(v.empty()) {
        cout << endl;
        return;
    }
    for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;
    cout << v.back() << endl;
}

using T = tuple<int, int, int>;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int h, w; cin >> h >> w;
    ll k; cin >> k;
    auto nx = vec3d(h, w, 8, T(0, 0, 0));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            for(int p = 0; p < 8; p++){
                int dx = (p&1) ? -1 : 1;
                int dy = (p&2) ? -1 : 1;
                bool flip = (p&4) ? false : true;
                if(flip){
                    if(0 <= i+dx && i+dx < h){
                        nx[i][j][p] = T(i+dx, j, p^4);
                    }else{
                        nx[i][j][p] = T(i, j, p^4^1);
                    }
                }else{
                    if(0 <= j+dy && j+dy < w){
                        nx[i][j][p] = T(i, j+dy, p^4);
                    }else{
                        nx[i][j][p] = T(i, j, p^4^2);
                    }
                }
            }
        }
    }
    return 0;
    auto seen = vec3d(h, w, 8, 0ll);
    int x = 0, y = 0, p = 0;
    vector<T> path;
    for(ll idx = 0; idx < k*2; idx++){
        if(seen[x][y][p] > 0){
            T t(x, y, p);
            ll head = 0;
            ll cycle = 0;
            for(int i = 0; i < path.size(); i++){
                if(t == path[i]){
                    head = i;
                    cycle = path.size()-head;
                    break;
                }
            }
            ll cnt_cycle = (k*2-head)/cycle;
            ll rem = (k*2-head)%cycle;
            vector<T> v_cycle;
            for(int i = head; i < path.size(); i++){
                v_cycle.push_back(path[i]);
            }
            for(int i = 0; i < cycle; i++){
                auto [xx, yy, pp] = v_cycle[i];
                seen[xx][yy][pp] += cnt_cycle-1;
                if(i < rem){
                    seen[xx][yy][pp]++;
                }
            }
            break;
        }
        path.push_back({x, y, p});
        seen[x][y][p]++;
        auto [xx, yy, pp] = nx[x][y][p];
        x = xx;
        y = yy;
        p = pp;
        assert(idx < 10*h*w);
    }
    auto ans = vec2d(h, w, 0);
    for(int x = 0; x < h; x++){
        for(int y = 0; y < w; y++){
            for(int p = 0; p < 4; p++){
                ans[x][y] ^= (seen[x][y][p]%2);
            }
            cout << (ans[x][y] == 0 ? '.' : '#');
        }
        cout << '\n';
    }
}
0