結果
問題 | No.866 レベルKの正方形 |
ユーザー | chocorusk |
提出日時 | 2019-08-16 22:17:43 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 2,143 ms / 6,000 ms |
コード長 | 1,309 bytes |
コンパイル時間 | 1,606 ms |
コンパイル使用メモリ | 104,740 KB |
実行使用メモリ | 418,260 KB |
最終ジャッジ日時 | 2023-10-24 00:44:10 |
合計ジャッジ時間 | 28,532 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge12 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 12 ms
56,984 KB |
testcase_01 | AC | 12 ms
56,984 KB |
testcase_02 | AC | 12 ms
56,984 KB |
testcase_03 | AC | 12 ms
56,984 KB |
testcase_04 | AC | 11 ms
56,984 KB |
testcase_05 | AC | 11 ms
56,984 KB |
testcase_06 | AC | 11 ms
56,984 KB |
testcase_07 | AC | 11 ms
56,984 KB |
testcase_08 | AC | 1,959 ms
418,052 KB |
testcase_09 | AC | 1,871 ms
418,260 KB |
testcase_10 | AC | 1,627 ms
418,260 KB |
testcase_11 | AC | 2,143 ms
418,260 KB |
testcase_12 | AC | 1,520 ms
418,260 KB |
testcase_13 | AC | 2,068 ms
418,260 KB |
testcase_14 | AC | 1,950 ms
418,260 KB |
testcase_15 | AC | 1,859 ms
418,260 KB |
testcase_16 | AC | 1,882 ms
418,260 KB |
testcase_17 | AC | 1,796 ms
418,260 KB |
testcase_18 | AC | 1,697 ms
418,260 KB |
testcase_19 | AC | 1,872 ms
418,260 KB |
testcase_20 | AC | 1,658 ms
418,260 KB |
testcase_21 | AC | 796 ms
418,260 KB |
testcase_22 | AC | 12 ms
56,936 KB |
testcase_23 | AC | 12 ms
56,936 KB |
testcase_24 | AC | 13 ms
59,056 KB |
ソースコード
#include <cstdio> #include <cstring> #include <iostream> #include <string> #include <cmath> #include <bitset> #include <vector> #include <map> #include <set> #include <queue> #include <deque> #include <algorithm> #include <complex> #include <unordered_map> #include <unordered_set> #include <random> #include <cassert> #include <fstream> #include <utility> #include <functional> #define popcount __builtin_popcount using namespace std; typedef long long int ll; typedef pair<int, int> P; int dp[26][2002][2002]; int h, w; string c[2002]; int main() { int k; cin>>h>>w>>k; for(int i=0; i<h; i++){ cin>>c[i]; } for(int i=0; i<h; i++){ for(int l=0; l<26; l++){ if(l==c[i][0]-'a') dp[l][i][0]=0; else dp[l][i][0]=1; } } for(int i=0; i<w; i++){ for(int l=0; l<26; l++){ if(l==c[0][i]-'a') dp[l][0][i]=0; else dp[l][0][i]=1; } } for(int i=1; i<h; i++){ for(int j=1; j<w; j++){ for(int l=0; l<26; l++){ if(c[i][j]-'a'==l) dp[l][i][j]=0; else{ dp[l][i][j]=min({dp[l][i-1][j-1], dp[l][i-1][j], dp[l][i][j-1]})+1; } } } } ll ans=0; for(int i=0; i<h; i++){ for(int j=0; j<w; j++){ int x[28]; for(int l=0; l<26; l++) x[l+1]=dp[l][i][j]; x[0]=0, x[27]=min(i+1, j+1); sort(x, x+28); ans+=(ll)(x[k+1]-x[k]); } } cout<<ans<<endl; return 0; }