結果
問題 | No.2456 Stamp Art |
ユーザー | Kude |
提出日時 | 2023-09-01 22:26:13 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 199 ms / 5,000 ms |
コード長 | 1,658 bytes |
コンパイル時間 | 3,058 ms |
コンパイル使用メモリ | 272,500 KB |
実行使用メモリ | 38,904 KB |
最終ジャッジ日時 | 2023-09-02 11:18:18 |
合計ジャッジ時間 | 7,425 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge16 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,380 KB |
testcase_03 | AC | 179 ms
38,852 KB |
testcase_04 | AC | 2 ms
4,376 KB |
testcase_05 | AC | 2 ms
4,376 KB |
testcase_06 | AC | 182 ms
38,904 KB |
testcase_07 | AC | 160 ms
36,176 KB |
testcase_08 | AC | 158 ms
38,616 KB |
testcase_09 | AC | 179 ms
38,652 KB |
testcase_10 | AC | 189 ms
38,820 KB |
testcase_11 | AC | 173 ms
38,868 KB |
testcase_12 | AC | 182 ms
38,836 KB |
testcase_13 | AC | 199 ms
38,816 KB |
testcase_14 | AC | 186 ms
38,864 KB |
testcase_15 | AC | 184 ms
38,844 KB |
testcase_16 | AC | 112 ms
36,676 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 2 ms
4,376 KB |
testcase_19 | AC | 111 ms
31,180 KB |
testcase_20 | AC | 193 ms
38,812 KB |
testcase_21 | AC | 177 ms
38,136 KB |
testcase_22 | AC | 191 ms
38,344 KB |
testcase_23 | AC | 29 ms
26,648 KB |
testcase_24 | AC | 24 ms
15,780 KB |
testcase_25 | AC | 2 ms
4,376 KB |
ソースコード
#include<bits/stdc++.h> namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include<atcoder/all> #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; int dp1[2010][2010]; int dp2[2010][2010]; } int main() { ios::sync_with_stdio(false); cin.tie(0); int h, w; cin >> h >> w; vector<string> s(h); rep(i, h) cin >> s[i]; for(int i = 1; i <= h; i++) { for(int j = 1; j <= w; j++) { if (s[i-1][j-1] == '.') continue; dp1[i][j] = min({dp1[i-1][j], dp1[i][j-1], dp1[i-1][j-1]}) + 1; } } int l = 0, r = 2010; while(r - l > 1) { int c = (l + r) / 2; rep(i, h + 1) rep(j, w + 1) dp2[i][j] = 0; rep(i, h + 1) rep(j, w + 1) if (dp1[i][j] >= c) { dp2[i-c][j-c]++; dp2[i-c][j]--; dp2[i][j-c]--; dp2[i][j]++; } rep(i, h) rep(j, w) dp2[i+1][j] += dp2[i][j]; rep(i, h) rep(j, w) dp2[i][j+1] += dp2[i][j]; bool ok = [&]() -> bool { rep(i, h) rep(j, w) if (s[i][j] == '#' && !dp2[i][j]) { return false; } return true; }(); (ok ? l : r) = c; } cout << l << '\n'; }