結果
| 問題 |
No.866 レベルKの正方形
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-08-17 03:45:37 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 744 bytes |
| コンパイル時間 | 870 ms |
| コンパイル使用メモリ | 66,168 KB |
| 実行使用メモリ | 424,404 KB |
| 最終ジャッジ日時 | 2024-09-24 18:10:23 |
| 合計ジャッジ時間 | 14,423 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | -- * 3 |
| other | AC * 7 WA * 3 TLE * 1 -- * 11 |
コンパイルメッセージ
main.cpp:28:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
28 | main()
| ^~~~
ソースコード
#include<iostream>
using namespace std;
int H,W,K;
string s[2000];
int sum[26][2001][2001];
int f(int x,int y,int k)
{
int L=1,R=(H-x<W-y?H-x:W-y)+1;
bool flag=false;
while(R-L>1)
{
int M=(L+R)/2;
int cnt=k;
for(int c=0;c<26;c++)
{
cnt-=sum[c][x+M][y+M]-sum[c][x+M][y]-sum[c][x][y+M]+sum[c][x][y]>0;
if(cnt<=0)break;
}
if(cnt>0)
{
if(cnt==1)flag=true;
L=M;
}
else R=M;
}
return flag?R-L:0;
}
main()
{
cin>>H>>W>>K;
for(int i=0;i<H;i++)cin>>s[i];
for(int c=0;c<26;c++)for(int i=0;i<H;i++)for(int j=0;j<W;j++)
{
sum[c][i+1][j+1]=sum[c][i+1][j]+sum[c][i][j+1]-sum[c][i][j]+(s[i][j]==c+'a');
}
long ans=0;
for(int i=0;i<H;i++)for(int j=0;j<W;j++)
{
int t=f(i,j,K+1);
ans+=t;
}
cout<<ans<<endl;
}