제출 #932745

#제출 시각아이디문제언어결과실행 시간메모리
932745maomao90화성 (APIO22_mars)C++17
36 / 100
112 ms4880 KiB

// 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;
    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';
    //}
    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;
    }
    string res;
    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;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...