結果
問題 | No.2456 Stamp Art |
ユーザー | kwm_t |
提出日時 | 2023-09-01 23:31:49 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,020 ms / 5,000 ms |
コード長 | 2,299 bytes |
コンパイル時間 | 2,506 ms |
コンパイル使用メモリ | 206,732 KB |
実行使用メモリ | 39,056 KB |
最終ジャッジ日時 | 2023-09-02 11:21:00 |
合計ジャッジ時間 | 18,050 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,376 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 2 ms
4,376 KB |
testcase_03 | AC | 892 ms
38,912 KB |
testcase_04 | AC | 1 ms
4,380 KB |
testcase_05 | AC | 2 ms
4,380 KB |
testcase_06 | AC | 947 ms
38,872 KB |
testcase_07 | AC | 996 ms
38,908 KB |
testcase_08 | AC | 887 ms
38,876 KB |
testcase_09 | AC | 964 ms
39,056 KB |
testcase_10 | AC | 992 ms
39,004 KB |
testcase_11 | AC | 927 ms
38,892 KB |
testcase_12 | AC | 898 ms
38,916 KB |
testcase_13 | AC | 1,020 ms
38,836 KB |
testcase_14 | AC | 1,007 ms
38,856 KB |
testcase_15 | AC | 901 ms
38,920 KB |
testcase_16 | AC | 464 ms
20,968 KB |
testcase_17 | AC | 2 ms
4,380 KB |
testcase_18 | AC | 1 ms
4,376 KB |
testcase_19 | AC | 241 ms
26,896 KB |
testcase_20 | AC | 939 ms
38,952 KB |
testcase_21 | AC | 884 ms
35,540 KB |
testcase_22 | AC | 999 ms
38,912 KB |
testcase_23 | AC | 17 ms
5,172 KB |
testcase_24 | AC | 29 ms
6,112 KB |
testcase_25 | AC | 2 ms
4,380 KB |
ソースコード
#include <bits/stdc++.h> //#include <atcoder/all> using namespace std; //using namespace atcoder; //using mint = modint1000000007; //const int mod = 1000000007; //using mint = modint998244353; //const int mod = 998244353; //const int INF = 1e9; //const long long LINF = 1e18; #define rep(i, n) for (int i = 0; i < (n); ++i) #define rep2(i,l,r)for(int i=(l);i<(r);++i) #define rrep(i, n) for (int i = (n-1); i >= 0; --i) #define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i) #define all(x) (x).begin(),(x).end() #define allR(x) (x).rbegin(),(x).rend() #define endl "\n" #define P pair<int,int> template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; } template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); int h, w; cin >> h >> w; vector<string>s(h); rep(i, h)cin >> s[i]; vector sc(h + 1, vector<int>(w + 1)); rep(i, h)rep(j, w)if ('#' == s[i][j])sc[i + 1][j + 1]++; rep(i, h + 1)rep(j, w) sc[i][j + 1] += sc[i][j]; rep(i, w + 1)rep(j, h) sc[j + 1][i] += sc[j][i]; // 左上(x0,y0)右下(x1,y1) auto calc = [&](int x0, int y0, int x1, int y1)->long long { return sc[x1 + 1][y1 + 1] - sc[x1 + 1][y0] - sc[x0][y1 + 1] + sc[x0][y0]; }; long long ng = max(h, w) + 1; long long ok = 1; while (1 < abs(ok - ng)) { long long mid = (ng + ok) / 2; //cout << mid << endl; vector imos(h + 1, vector<int>(w + 1)); auto add = [&](int x0, int y0, int x1, int y1, int val)->void { imos[x0][y0] += val; imos[x0][y1] -= val; imos[x1][y0] -= val; imos[x1][y1] += val; }; auto check = [&]() { rep(i, h - mid + 1)rep(j, w - mid + 1) { int cnt = calc(i, j, i + mid - 1, j + mid - 1); //cout << cnt << endl; if (cnt != mid * mid)continue; add(i, j, i + mid, j + mid, 1); } rep(i, h + 1) rep(j, w) imos[i][j + 1] += imos[i][j]; rep(i, w + 1) rep(j, h) imos[j + 1][i] += imos[j][i]; bool chk = true; rep(i, h)rep(j, w)if ('#' == s[i][j] && 0 == imos[i][j])chk = false; /*rep(i, h) { rep(j, w) { cout << imos[i][j]; } cout << endl; }*/ return chk; }; if (check()) ok = mid; else ng = mid; } cout << ok << endl; return 0; }