結果
問題 | No.866 レベルKの正方形 |
ユーザー | 👑 kmjp |
提出日時 | 2019-08-16 22:13:46 |
言語 | C++14 (gcc 13.2.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,908 ms / 6,000 ms |
コード長 | 1,473 bytes |
コンパイル時間 | 2,519 ms |
コンパイル使用メモリ | 169,876 KB |
実行使用メモリ | 449,620 KB |
最終ジャッジ日時 | 2023-10-24 00:15:10 |
合計ジャッジ時間 | 26,412 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 3 ms
5,836 KB |
testcase_01 | AC | 3 ms
5,836 KB |
testcase_02 | AC | 3 ms
5,836 KB |
testcase_03 | AC | 2 ms
5,836 KB |
testcase_04 | AC | 3 ms
5,836 KB |
testcase_05 | AC | 2 ms
5,836 KB |
testcase_06 | AC | 3 ms
5,836 KB |
testcase_07 | AC | 2 ms
5,836 KB |
testcase_08 | AC | 1,671 ms
449,616 KB |
testcase_09 | AC | 1,600 ms
449,620 KB |
testcase_10 | AC | 1,874 ms
449,620 KB |
testcase_11 | AC | 1,908 ms
449,620 KB |
testcase_12 | AC | 1,390 ms
449,620 KB |
testcase_13 | AC | 1,831 ms
449,620 KB |
testcase_14 | AC | 1,389 ms
449,620 KB |
testcase_15 | AC | 1,773 ms
449,620 KB |
testcase_16 | AC | 1,684 ms
449,620 KB |
testcase_17 | AC | 1,804 ms
449,620 KB |
testcase_18 | AC | 1,752 ms
449,620 KB |
testcase_19 | AC | 1,240 ms
449,620 KB |
testcase_20 | AC | 1,118 ms
449,620 KB |
testcase_21 | AC | 1,007 ms
449,616 KB |
testcase_22 | AC | 2 ms
5,784 KB |
testcase_23 | AC | 3 ms
5,784 KB |
testcase_24 | AC | 3 ms
5,964 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef signed long long ll; #undef _P #define _P(...) (void)printf(__VA_ARGS__) #define FOR(x,to) for(x=0;x<(to);x++) #define FORR(x,arr) for(auto& x:arr) #define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++) #define ALL(a) (a.begin()),(a.end()) #define ZERO(a) memset(a,0,sizeof(a)) #define MINUS(a) memset(a,0xff,sizeof(a)) //------------------------------------------------------- int H,W,K; string S[2020]; int C[2020][2020][26]; int PL[2020][2020]; int PR[2020][2020]; int num(int y,int x,int s) { int num=0,i; FOR(i,26) if(C[y+s][x+s][i]-C[y][x+s][i]-C[y+s][x][i]+C[y][x][i]>0) { num++; if(num>K) return num; if(num+(26-i)<K) return num; } return num; } void solve() { int i,j,k,l,r,x,y; string s; cin>>H>>W>>K; FOR(y,H) { cin>>S[y]; FOR(x,W) { FOR(i,26) { C[y+1][x+1][i]=C[y][x+1][i]+C[y+1][x][i]-C[y][x][i]; if(S[y][x]=='a'+i) C[y+1][x+1][i]++; } } } ll ret=0; FOR(y,H) FOR(x,W) { int L=0,R=0; if(y&&x) { L=max(0,PL[y-1][x-1]-1); R=max(0,PR[y-1][x-1]-1); } while(y+L+1<=H&&x+L+1<=W&&num(y,x,L+1)<K) L++; while(y+R+1<=H&&x+R+1<=W&&num(y,x,R+1)<=K) R++; PL[y][x]=L; PR[y][x]=R; ret+=R-L; } cout<<ret<<endl; } int main(int argc,char** argv){ string s;int i; if(argc==1) ios::sync_with_stdio(false), cin.tie(0); FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin); cout.tie(0); solve(); return 0; }