結果
| 問題 | No.2412 YOU Grow Bigger! | 
| コンテスト | |
| ユーザー |  houren | 
| 提出日時 | 2023-08-11 22:33:35 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,615 bytes | 
| コンパイル時間 | 2,145 ms | 
| コンパイル使用メモリ | 191,972 KB | 
| 実行使用メモリ | 6,824 KB | 
| 最終ジャッジ日時 | 2024-11-18 17:20:50 | 
| 合計ジャッジ時間 | 3,313 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 20 WA * 9 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/maxflow>
using namespace atcoder;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);
int H[] = {0,1,0,-1}, W[] = {1,0,-1,0};
bool f(int p, int q, vector<string>& s){
    for(int i=p-1;i<=p+1;i++)for(int j=q-1;j<=q+1;j++) if(s[i][j]=='#') return false;
    return true;
}
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int h,w;
    cin >> h >> w;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    mf_graph<int> g((h-2)*(w-2));
    vector<vector<bool>> seen(h,vector<bool>(w,false));
    rep(i,h) seen[i][0] = seen[i][w-1] = true;
    rep(i,w) seen[0][i] = seen[h-1][i] = true;
    queue<pair<int,int>> que;
    que.push({1,1});
    seen[1][1] = true;
    while(que.size()){
        int p,q;
        tie(p,q) = que.front();
        que.pop();
        rep(i,4){
            int np = p+H[i], nq = q+W[i];
            if(seen[np][nq] || !f(np,nq,s)) continue;
            seen[np][nq] = true;
            g.add_edge((p-1)*(w-2)+(q-1), (np-1)*(w-2)+(nq-1),1);
            g.add_edge((np-1)*(w-2)+(nq-1), (p-1)*(w-2)+(q-1),1);
            que.push({np,nq});
        }
    }
    cout << g.flow(0, (h-2)*(w-2)-1) << '\n';
    return 0;
}
            
            
            
        