結果

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

ソースコード

diff #
raw source code

#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
using namespace std;
using ll = long long;
using P = pair<int, int>;

bool reach(int n, vector<string>& s){
  vector ok(n, vector<int>(n));
  queue<P> bfs;
  bfs.emplace(0, 0);
  int di[4]={-1, 0, 1, 0};
  int dj[4]={0, 1, 0, -1};
  while(bfs.size()){
    auto [i, j]=bfs.front(); bfs.pop();
    if(ok[i][j]) continue;
    ok[i][j]=1;
    for(int k=0; k<4; k++){
      int ni=i+di[k], nj=j+dj[k];
      if(ni<0||nj<0||ni>=n||nj>=n) continue;
      if(s[ni][nj]=='#') continue;
      bfs.emplace(ni, nj);
    }
  }
  return ok[n-1][n-1];
}

void Print(vector<string>& s){
  for(auto&p:s) cout << p << endl;
}


void exp(int n){
  ll mx=(1ll<<(n*n));
  map<vector<string>, bool> goal;
  set<vector<string>> all;
  for(ll i=0; i<mx; i++){
    if((i&1)||(i>>(n*n-1)&1)) continue;
    vector<string> now(n, string(n, '.'));
    for(int j=0; j<n; j++)for(int k=0; k<n; k++){
      int p=j*n+k;
      if(i>>p&1) now[j][k]='#';
    }
    goal[now]=reach(n, now);
    all.insert(now);
  }
  for(ll i=0; i<mx; i++){
    if((i&1)||(i>>(n*n-1)&1)) continue;
    vector<string> now(n, string(n, '.'));
    for(int j=0; j<n; j++)for(int k=0; k<n; k++){
      int p=j*n+k;
      if(i>>p&1) now[j][k]='#';
    }
    bool alice_win=true;
    {
      for(int li=1; li<n-1; li++){
        for(int ri=li; ri<n-1; ri++){
          vector<string> t=now;
          for(int ni=li; ni<=ri; ni++)for(int nj=0; nj<n; nj++) t[ni][nj]=(t[ni][nj]=='.'?'#':'.');
          if(!goal[t]){
            alice_win=false; break;
          }
        }
        if(!alice_win) break;
      }
    }
    if(!alice_win) continue;
    {
      for(int lj=1; lj<n-1; lj++){
        for(int rj=lj; rj<n-1; rj++){
          vector<string> t=now;
          for(int ni=0; ni<n; ni++)for(int nj=lj; nj<=rj; nj++) t[ni][nj]=(t[ni][nj]=='.'?'#':'.');
          if(!goal[t]){
            alice_win=false; break;
          }
        }
      }
    }
    if(alice_win){
      for(auto p:now) cout << p << endl; return;
    }
  }
  cout << "Nothing" << endl;
}

int main(void){
  //exp(6);
  int n; cin >> n;
  for(int i=0; i<n; i++)for(int j=0; j<n; j++){
    cout << (n-2<=i+j&&i+j<=n-1?'#':'.');
    if(j==n-1) cout << endl;
  }
  return 0; 
}
0