結果
| 問題 |
No.866 レベルKの正方形
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-16 22:52:06 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2,763 ms / 6,000 ms |
| コード長 | 1,993 bytes |
| コンパイル時間 | 1,436 ms |
| コンパイル使用メモリ | 113,176 KB |
| 実行使用メモリ | 416,248 KB |
| 最終ジャッジ日時 | 2024-09-22 20:10:00 |
| 合計ジャッジ時間 | 32,975 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 22 |
ソースコード
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <cassert>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
using Int = long long;
template <class T1, class T2> ostream &operator<<(ostream &os, const pair<T1, T2> &a) { return os << "(" << a.first << ", " << a.second << ")"; };
template <class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cerr << *i << " "; cerr << endl; }
template <class T> void chmin(T &t, const T &f) { if (t > f) t = f; }
template <class T> void chmax(T &t, const T &f) { if (t < f) t = f; }
int H, W, K;
char C[2010][2010];
int sum[26][2010][2010];
inline int calc(int e, int x0, int x1, int y0, int y1) {
return sum[e][x0][y0] - sum[e][x0][y1] - sum[e][x1][y0] + sum[e][x1][y1];
}
inline int get(int x, int y, int l) {
int ret = 0;
for (int e = 0; e < 26; ++e) {
if (calc(e, x, x + l, y, y + l) > 0) {
++ret;
}
}
return ret;
}
int main() {
for (; ~scanf("%d%d%d", &H, &W, &K); ) {
for (int x = 0; x < H; ++x) {
scanf("%s", C[x]);
}
for (int e = 0; e < 26; ++e) {
for (int x = 0; x < H; ++x) for (int y = 0; y < W; ++y) {
sum[e][x + 1][y + 1] = sum[e][x + 1][y] + sum[e][x][y + 1] - sum[e][x][y] + ((C[x][y] - 'a' == e) ? 1 : 0);
}
}
Int ans = 0;
for (int s = 0; s < 2; ++s) {
for (int x = 0; x < H; ++x) {
int l = 1;
for (int y = 0; y < W; ++y) {
--l;
for (; x + l <= H && y + l <= W && get(x, y, l) < K + s; ++l) {}
ans += (s == 0) ? -l : +l;
}
}
}
printf("%lld\n", ans);
}
return 0;
}