結果
問題 | No.866 レベルKの正方形 |
ユーザー | 👑 jupiro |
提出日時 | 2020-01-31 02:57:24 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,991 ms / 6,000 ms |
コード長 | 1,687 bytes |
コンパイル時間 | 1,513 ms |
コンパイル使用メモリ | 116,076 KB |
実行使用メモリ | 415,560 KB |
最終ジャッジ日時 | 2023-10-14 14:02:11 |
合計ジャッジ時間 | 39,467 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,468 KB |
testcase_01 | AC | 2 ms
5,516 KB |
testcase_02 | AC | 2 ms
5,596 KB |
testcase_03 | AC | 1 ms
5,484 KB |
testcase_04 | AC | 2 ms
5,600 KB |
testcase_05 | AC | 2 ms
5,664 KB |
testcase_06 | AC | 2 ms
5,552 KB |
testcase_07 | AC | 2 ms
5,496 KB |
testcase_08 | AC | 2,991 ms
415,476 KB |
testcase_09 | AC | 2,451 ms
415,484 KB |
testcase_10 | AC | 2,256 ms
415,392 KB |
testcase_11 | AC | 2,907 ms
415,388 KB |
testcase_12 | AC | 2,479 ms
415,316 KB |
testcase_13 | AC | 2,912 ms
415,300 KB |
testcase_14 | AC | 2,530 ms
415,288 KB |
testcase_15 | AC | 2,761 ms
415,332 KB |
testcase_16 | AC | 2,700 ms
415,376 KB |
testcase_17 | AC | 2,556 ms
415,324 KB |
testcase_18 | AC | 2,797 ms
415,560 KB |
testcase_19 | AC | 2,923 ms
415,260 KB |
testcase_20 | AC | 2,637 ms
415,324 KB |
testcase_21 | AC | 1,611 ms
415,448 KB |
testcase_22 | AC | 2 ms
4,352 KB |
testcase_23 | AC | 2 ms
4,352 KB |
testcase_24 | AC | 2 ms
7,548 KB |
ソースコード
#include <cstdio> #include <iostream> #include <string> #include <sstream> #include <stack> #include <algorithm> #include <cmath> #include <queue> #include <map> #include <set> #include <cstdlib> #include <bitset> #include <tuple> #include <assert.h> #include <deque> #include <bitset> #include <iomanip> #include <limits> #include <chrono> #include <random> #include <array> #include <unordered_map> #include <functional> #include <complex> template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } const long long MAX = 5100000; const long long INF = 1LL << 60; //const long long mod = 1000000007LL; //const long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; int dp[2007][2007][26]; string vs[2007]; int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll H, W, K; cin >> H >> W >> K; for (ll i = 0; i < H; i++) { cin >> vs[i]; } for (ll i = 0; i <= H; i++)for (ll j = 0; j <= W; j++)for (ll k = 0; k < 26; k++) dp[i][j][k] = (1 << 30); for (ll k = 0; k < 26; k++) { for (ll i = H - 1; i >= 0; i--) { for (ll j = W - 1; j >= 0; j--) { int f = min(H - i, W - j); if (vs[i][j] - 'a' == k) dp[i][j][k] = 1; else dp[i][j][k] = min({ f,dp[i + 1][j][k],dp[i][j + 1][k],dp[i + 1][j + 1][k] }) + 1; } } } ll res = 0; for (ll i = 0; i < H; i++) { for (ll j = 0; j < W; j++) { sort(dp[i][j], dp[i][j] + 26); if (K == 26) res += min(H - i, W - j) + 1 - dp[i][j][K - 1]; else res += dp[i][j][K] - dp[i][j][K - 1]; } } cout << res << endl; return 0; }