結果
問題 |
No.866 レベルKの正方形
|
ユーザー |
|
提出日時 | 2020-03-13 21:22:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,962 bytes |
コンパイル時間 | 1,254 ms |
コンパイル使用メモリ | 117,104 KB |
実行使用メモリ | 485,928 KB |
最終ジャッジ日時 | 2024-11-22 19:18:18 |
合計ジャッジ時間 | 34,254 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 19 WA * 3 |
ソースコード
#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; } constexpr long long MAX = 5100000; constexpr long long INF = 1LL << 60; constexpr int inf = 1 << 28; //constexpr long long mod = 1000000007LL; //constexpr long long mod = 998244353LL; using namespace std; typedef unsigned long long ull; typedef long long ll; bool a[26][2001][2001]; char s[2010]; int dp[26][2001][2001]; int srt[26]; int main() { /* cin.tie(nullptr); ios::sync_with_stdio(false); */ int H, W, K; scanf("%d %d %d", &H, &W, &K); for (int i = 0; i < 26; i++) for (int j = 0; j <= H; j++) for (int k = 0; k <= W; k++) dp[i][j][k] = min(H - j + 1, W - k + 1); for (int i = 0; i < H; i++) { scanf("%s", s); for (int j = 0; j < W; j++) { a[s[j] - 'a'][i][j] = true; dp[s[j] - 'a'][i][j] = 1; } } for (int i = 0; i < 26; i++) { for (int j = H - 1; j >= 0; j--) { for (int k = W - 1; k >= 0; k--) { chmin(dp[i][j][k], dp[i][j + 1][k] + 1); chmin(dp[i][j][k], dp[i][j][k + 1] + 1); chmin(dp[i][j][k], dp[i][j + 1][k + 1] + 1); } } } ll res = 0; for (int i = 0; i < H; i++) { for (int j = 0; j < W; j++) { for (int k = 0; k < 26; k++) { srt[k] = dp[k][i][j]; } sort(srt, srt + 26); res += srt[K] - srt[K - 1]; } } printf("%lld\n", res); return 0; /* おまじないを使ったらscanfとprintf関連注意!!!!!!!!!!!! */ }