結果

問題 No.3725 Exploit Wall
コンテスト
ユーザー shingo0909
提出日時 2026-09-19 14:05:06
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 2,000 ms
+ 382µs
コード長 3,291 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 2,132 ms
コンパイル使用メモリ 335,972 KB
実行使用メモリ 10,028 KB
最終ジャッジ日時 2026-09-19 14:05:16
合計ジャッジ時間 8,596 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge4_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 59
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// https://github.com/shingo0909/kyopro/blob/39029fab39c1735c38e5e9e4494d9934f81d6918/Library/GridBFS.cpp

struct GridBFS {
  private:
    int H, W;
    vector<string> grid;
    vector<vector<ll>> d;

    static constexpr ll INF = 1LL << 62;
    static constexpr int dx[] = {0, 0, 1, -1};
    static constexpr int dy[] = {1, -1, 0, 0};

  public:
    GridBFS(vector<string> &grid)
        : H(grid.size()), W(grid[0].size()), grid(grid) {}

    void bfs(int sx, int sy) {
        d.assign(H, vector<ll>(W, INF));
        queue<pair<int, int>> q;
        d[sx][sy] = 0;
        q.push({sx, sy});
        while (!q.empty()) {
            auto [x, y] = q.front();
            q.pop();
            for (int dir = 0; dir < 4; dir++) {
                int nx = x + dx[dir];
                int ny = y + dy[dir];
                if (nx < 0 || nx >= H || ny < 0 || ny >= W)
                    continue;
                if (grid[nx][ny] == '#')
                    continue;
                if (d[nx][ny] != INF)
                    continue;
                d[nx][ny] = d[x][y] + 1;
                q.push({nx, ny});
            }
        }
    }

    ll dist(int x, int y) const {
        return d[x][y] == INF ? -1 : d[x][y];
    }
};

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    // rep(i, 1 << (n * n)) {
    //     vector<string> s(n);
    //     rep(j, n * n) {
    //         if (i >> j & 1) {
    //             s[j / n].push_back('#');
    //         } else
    //             s[j / n].push_back('.');
    //     }
    //     if (s[0][0] == '#' || s.back().back() == '#')
    //         continue;
    //     bool ok = true;
    //     rep(l, n - 1) rep(r, n) {
    //         if (l == 0 || l >= r)
    //             continue;
    //         for (int k = l; k < r; k++) {
    //             rep(x, n) s[k][x] = (s[k][x] == '#') ? '.' : '#';
    //         }
    //         GridBFS g(s);
    //         g.bfs(0, 0);
    //         if (g.dist(n - 1, n - 1) == -1) {
    //             ok = false;
    //         }
    //         for (int k = l; k < r; k++) {
    //             rep(x, n) s[k][x] = (s[k][x] == '#') ? '.' : '#';
    //         }
    //     }
    //     auto t = s;
    //     rep(i, n) rep(j, n) s[j][i] = t[i][j];
    //     rep(l, n - 1) rep(r, n) {
    //         if (l == 0 || l >= r)
    //             continue;
    //         for (int k = l; k < r; k++) {
    //             rep(x, n) s[k][x] = (s[k][x] == '#') ? '.' : '#';
    //         }
    //         GridBFS g(s);
    //         g.bfs(0, 0);
    //         if (g.dist(n - 1, n - 1) == -1) {
    //             ok = false;
    //         }
    //         for (int k = l; k < r; k++) {
    //             rep(x, n) s[k][x] = (s[k][x] == '#') ? '.' : '#';
    //         }
    //     }
    //     if (ok) {
    //         for (string t : s)
    //             cout << t << endl;
    //         cout << endl;
    //     }
    // }
    rep(i, n) {
        rep(j, n) {
            if (abs(n - i - 1 - j) <= 1)
                cout << '#';
            else
                cout << '.';
        }
        cout << endl;
    }
    return 0;
}
0