結果
問題 | No.866 レベルKの正方形 |
ユーザー | tko919 |
提出日時 | 2019-08-31 14:07:46 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 3,978 ms / 6,000 ms |
コード長 | 1,443 bytes |
コンパイル時間 | 1,751 ms |
コンパイル使用メモリ | 165,792 KB |
実行使用メモリ | 410,424 KB |
最終ジャッジ日時 | 2023-08-16 05:33:33 |
合計ジャッジ時間 | 52,830 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,384 KB |
testcase_01 | AC | 1 ms
4,380 KB |
testcase_02 | AC | 1 ms
4,380 KB |
testcase_03 | AC | 1 ms
4,384 KB |
testcase_04 | AC | 2 ms
4,384 KB |
testcase_05 | AC | 1 ms
4,384 KB |
testcase_06 | AC | 1 ms
4,380 KB |
testcase_07 | AC | 2 ms
4,388 KB |
testcase_08 | AC | 2,730 ms
410,212 KB |
testcase_09 | AC | 2,991 ms
410,120 KB |
testcase_10 | AC | 3,204 ms
410,128 KB |
testcase_11 | AC | 3,342 ms
410,176 KB |
testcase_12 | AC | 3,575 ms
410,180 KB |
testcase_13 | AC | 3,264 ms
410,128 KB |
testcase_14 | AC | 3,978 ms
410,424 KB |
testcase_15 | AC | 3,182 ms
410,312 KB |
testcase_16 | AC | 3,752 ms
410,200 KB |
testcase_17 | AC | 3,538 ms
410,304 KB |
testcase_18 | AC | 3,381 ms
410,132 KB |
testcase_19 | AC | 3,703 ms
410,204 KB |
testcase_20 | AC | 3,288 ms
410,196 KB |
testcase_21 | AC | 3,923 ms
410,232 KB |
testcase_22 | AC | 2 ms
4,384 KB |
testcase_23 | AC | 2 ms
4,380 KB |
testcase_24 | AC | 2 ms
5,640 KB |
ソースコード
#define _USE_MATH_DEFINES #include <bits/stdc++.h> using namespace std; //template #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(a);i>(b);i--) #define ALL(v) (v).begin(),(v).end() typedef long long int ll; typedef pair<ll, ll> P; 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; } template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);} const int inf=INT_MAX/2; const ll INF=LLONG_MAX/2; //template end int h,w,k; int imos[2001][2001][26]={}; int rui(int x1,int y1,int x2,int y2){ int res=0; rep(i,0,26)if(imos[x2][y2][i]-imos[x1][y2][i]-imos[x2][y1][i]+imos[x1][y1][i]!=0)res++; return res; } int search(int x,int y,int a){ int l=-1,r=min(h-x,w-y)+1,mid; while(r-l>1){ mid=(l+r)/2; if(rui(x,y,x+mid,y+mid)>=a)r=mid; else l=mid; } return r; } int main(){ scanf("%d%d%d",&h,&w,&k); rep(i,0,h)rep(j,0,w){ char c; cin>>c; imos[i+1][j+1][c-'a']++; } rep(i,0,h)rep(j,0,w+1)rep(l,0,26)imos[i+1][j][l]+=imos[i][j][l]; rep(i,0,h+1)rep(j,0,w)rep(l,0,26)imos[i][j+1][l]+=imos[i][j][l]; ll ans=0,add; rep(i,0,h)rep(j,0,w){ add=search(i,j,k+1)-search(i,j,k); ans+=add; } printf("%lld\n",ans); return 0; }