結果
| 問題 |
No.866 レベルKの正方形
|
| コンテスト | |
| ユーザー |
tnakao0123
|
| 提出日時 | 2019-08-19 15:27:11 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,580 bytes |
| コンパイル時間 | 655 ms |
| コンパイル使用メモリ | 85,960 KB |
| 実行使用メモリ | 416,588 KB |
| 最終ジャッジ日時 | 2024-10-04 10:43:52 |
| 合計ジャッジ時間 | 9,832 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 8 TLE * 1 -- * 13 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:63:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
63 | scanf("%d%d%d", &h, &w, &k);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~
main.cpp:66:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
66 | scanf("%s", s);
| ~~~~~^~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*-
*
* 866.cc: No.866 レベルKの正方形 - yukicoder
*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
using namespace std;
/* constant */
const int MAX_H = 2000;
const int MAX_W = 2000;
/* typedef */
typedef long long ll;
/* global variables */
char s[MAX_W + 4];
int css[26][MAX_H + 1][MAX_W + 1];
/* subroutines */
inline int stlb(int i, int j, int maxl, int k) {
int l0 = 0, l1 = maxl + 1;
while (l0 + 1 < l1) {
int l = (l0 + l1) / 2;
int num = 0;
for (int c = 0; c < 26; c++)
if (css[c][i + l][j + l] - css[c][i + l][j] - css[c][i][j + l]
+ css[c][i][j] > 0) num++;
if (num >= k) l1 = l;
else l0 = l;
}
return l1;
}
/* main */
int main() {
int h, w, k;
scanf("%d%d%d", &h, &w, &k);
for (int i = 0; i < h; i++) {
scanf("%s", s);
for (int j = 0; j < w; j++) {
int cij = s[j] - 'a';
for (int c = 0; c < 26; c++)
css[c][i + 1][j + 1] =
((cij == c) ? 1 : 0)
+ css[c][i + 1][j] + css[c][i][j + 1] - css[c][i][j];
}
}
ll sum = 0;
for (int i = 0; i < h; i++)
for (int j = 0; j < w; j++) {
int maxl = min(h - i, w - j);
int l0 = stlb(i, j, maxl, k);
if (l0 <= maxl) {
int l1 = stlb(i, j, maxl, k + 1);
sum += l1 - l0;
}
}
printf("%lld\n", sum);
return 0;
}
tnakao0123