답안 #933246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933246 2024-02-25T10:08:14 Z maomao90 화성 (APIO22_mars) C++17
0 / 100
1 ms 332 KB
// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
#include "mars.h"
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return a > b ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 200005;
const int dirr[] = {1, 0, -1, 0}, dirc[] = {0, 1, 0, -1};

string process(vector<vector<string>> a, int i, int j, int k, int n) {
    int tn = 3 + 2 * k, m = 2 * (n - k - 1);
    int HALFN = (n + 1) / 2 * 2 + 1;
    int BORDER = 2 * n - HALFN + 1;
    // 3 + 2 * k == HALFN
    // k = (HALFN - 3) / 2
    if (tn <= HALFN) {
        vector<string> grid(tn, string(tn, '0'));
        REP (x, 0, 3) {
            REP (y, 0, 3) {
                REP (p, 0, (k + 1) * (k + 1)) {
                    int r = x + 2 * (p / (k + 1)),
                        c = y + 2 * (p % (k + 1));
                    grid[r][c] = a[x][y][p];
                }
            }
        }
        //cerr << i << ' ' << j << ' ' << k << '\n';
        //REP (r, 0, tn) {
            //cerr << grid[r] << '\n';
        //}
        string res;
        if (tn == HALFN) {
            if (m - 1 <= i && m - 2 <= j) {
                // m - 1 <= r <= 2 * n
                // 2 * n - HALFN + 1 <= r <= 2 * n
                // m - 2 <= c <= 2 * n
                //for (int r = 2 * n - (m - i); r >= i; r -= 2) {
                    //for (int c = 2 * n - (m - j); c >= j; c -= 3) {
                for (int r = 2 * n - (m - i); r >= BORDER; r -= 2) {
                    for (int c = 2 * n - (m - j); c >= BORDER; c -= 3) {
                        res += grid[r - i][c - j];
                    }
                }
            } else if (i < 2 && j < 3) {
                //for (int r = i; r < i + tn; r += 2) {
                    //for (int c = j; c < j + tn; c += 3) {
                for (int r = i; r < BORDER; r += 2) {
                    for (int c = j; c < BORDER; c += 3) {
                        res += grid[r - i][c - j];
                    }
                }
            } else if (i < 3 && m - 1 <= j) {
                //for (int r = i; r < i + tn; r += 3) {
                for (int r = i; r < BORDER; r += 3) {
                    //for (int c = 2 * n - (m - j); c >= j; c -= 2) {
                    for (int c = 2 * n - (m - j); c >= BORDER; c -= 2) {
                        res += grid[r - i][c - j];
                    }
                }
            } else if (m - 2 <= i && j < 2) {
                //for (int r = 2 * n - (m - i); r >= i; r -= 3) {
                for (int r = 2 * n - (m - i); r >= BORDER; r -= 3) {
                    //for (int c = j; c < j + tn; c += 2) {
                    for (int c = j; c < BORDER; c += 2) {
                        res += grid[r - i][c - j];
                    }
                }
            }
        }
        for (int r = 0; r < tn; r += 2) {
            for (int c = 0; c < tn; c += 2) {
                res += grid[r][c];
            }
        }
        res.resize(100, '0');
        return res;
    } else if (k < n - 2) {
        if (m - 1 <= i && m - 2 <= j) {
            return a[2][2];
        } else if (i < 2 && j < 3) {
            return a[0][0];
        } else if (i < 3 && m - 1 <= j) {
            return a[0][2];
        } else if (m - 2 <= i && j < 2) {
            return a[2][0];
        } else {
            return string(100, '0');
        }
    } else if (k == n - 2) {
        vector<string> grid;
        if (i == 2 && j == 2) {
            grid = vector<string>(2 * n + 1 - BORDER, string(2 * n + 1 - BORDER, '0'));
            REP (di, 1, 3) {
                REP (dj, 0, 3) {
                    int ptr = 0;
                    for (int r = 2 * n - (2 - di); r >= BORDER; r -= 2) {
                        for (int c = 2 * n - (2 - dj); c >= BORDER; c -= 3) {
                            grid[r - BORDER][c - BORDER] = a[di][dj][ptr++];
                        }
                    }
                }
            }
        } else if (i == 0 && j == 0) {
            grid = vector<string>(BORDER, string(BORDER, '0'));
            REP (di, 0, 2) {
                REP (dj, 0, 3) {
                    int ptr = 0;
                    for (int r = di; r < BORDER; r += 2) {
                        for (int c = dj; c < BORDER; c += 3) {
                            grid[r][c] = a[di][dj][ptr++];
                        }
                    }
                }
            }
        } else if (i == 0 && j == 2) {
        } else if (i == 2 && j == 0) {
        } else {
            return string(100, '0');
        }
        cerr << i << ' ' << j << '\n';
        REP (i, 0, SZ(grid)) {
            cerr << grid[i] << '\n';
        }
    } else {
        assert(k == n - 1);
    }
    return string(100, '0');
    /*
    if (k == n - 1) {
        vector<vector<bool>> vis(tn, vector<bool>(tn, 0));
        int comp = 0;
        REP (r, 0, tn) {
            REP (c, 0, tn) {
                if (vis[r][c] || grid[r][c] == '0') {
                    continue;
                }
                comp++;
                queue<ii> bfs;
                bfs.push({r, c});
                vis[r][c] = 1;
                while (!bfs.empty()) {
                    auto [ur, uc] = bfs.front(); bfs.pop();
                    REP (k, 0, 4) {
                        int vr = ur + dirr[k], vc = uc + dirc[k];
                        if (vr < 0 || vr >= tn || vc < 0 || vc >= tn) {
                            continue;
                        }
                        if (grid[vr][vc] == '0' || vis[vr][vc]) {
                            continue;
                        }
                        bfs.push({vr, vc});
                        vis[vr][vc] = 1;
                    }
                }
            }
        }
        string res(100, '0');
        REP (k, 0, 30) {
            if (comp >> k & 1) {
                res[k] = '1';
            }
        }
        return res;
    }
    */
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 332 KB Incorrect
2 Halted 0 ms 0 KB -