結果
問題 | No.866 レベルKの正方形 |
ユーザー |
|
提出日時 | 2019-08-17 04:07:31 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 703 bytes |
コンパイル時間 | 703 ms |
コンパイル使用メモリ | 61,688 KB |
実行使用メモリ | 409,720 KB |
最終ジャッジ日時 | 2024-09-24 18:35:28 |
合計ジャッジ時間 | 43,760 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 21 WA * 1 |
コンパイルメッセージ
main.cpp:21:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 21 | main() | ^~~~
ソースコード
#include<ios>using namespace std;int H,W,K;int sum[2001][2001][26];inline int f(int x,int y,int k){int L=1,R=(H-x<W-y?H-x:W-y)+1;while(R-L>1){int M=(L+R)/2;int cnt=k;for(int c=0;c<26;c++){cnt-=sum[x+M][y+M][c]-sum[x+M][y][c]-sum[x][y+M][c]+sum[x][y][c]>0;}if(cnt>0)L=M;else R=M;}return R;}main(){scanf("%d%d%d",&H,&W,&K);for(int i=0;i<H;i++){getchar_unlocked();for(int j=0;j<W;j++){int s=getchar_unlocked()-'a';for(int c=0;c<26;c++){sum[i+1][j+1][c]=sum[i+1][j][c]+sum[i][j+1][c]-sum[i][j][c]+(s==c);}}}long ans=0;for(int i=0;i<H;i++)for(int j=0;j<W;j++){ans+=f(i,j,K+1)-f(i,j,K);}printf("%ld\n",ans);}