結果
問題 | No.866 レベルKの正方形 |
ユーザー |
![]() |
提出日時 | 2019-08-16 22:17:43 |
言語 | C++11 (gcc 8.5.0) |
結果 |
AC
|
実行時間 | 2,147 ms / 6,000 ms |
コード長 | 1,309 bytes |
コンパイル時間 | 1,122 ms |
使用メモリ | 417,944 KB |
最終ジャッジ日時 | 2022-11-22 07:42:33 |
合計ジャッジ時間 | 28,501 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
テストケース
テストケース表示入力 | 結果 | 実行時間 使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
4,480 KB |
testcase_01 | AC | 4 ms
4,636 KB |
testcase_02 | AC | 3 ms
4,584 KB |
testcase_03 | AC | 3 ms
4,528 KB |
testcase_04 | AC | 3 ms
4,528 KB |
testcase_05 | AC | 3 ms
4,604 KB |
testcase_06 | AC | 2 ms
4,596 KB |
testcase_07 | AC | 3 ms
4,552 KB |
testcase_08 | AC | 1,815 ms
417,944 KB |
testcase_09 | AC | 1,853 ms
417,816 KB |
testcase_10 | AC | 1,641 ms
417,792 KB |
testcase_11 | AC | 2,147 ms
417,892 KB |
testcase_12 | AC | 1,577 ms
417,896 KB |
testcase_13 | AC | 2,062 ms
417,724 KB |
testcase_14 | AC | 1,948 ms
417,896 KB |
testcase_15 | AC | 1,789 ms
417,800 KB |
testcase_16 | AC | 1,902 ms
417,880 KB |
testcase_17 | AC | 1,831 ms
417,880 KB |
testcase_18 | AC | 1,750 ms
417,868 KB |
testcase_19 | AC | 1,881 ms
417,868 KB |
testcase_20 | AC | 1,705 ms
417,856 KB |
testcase_21 | AC | 847 ms
417,896 KB |
testcase_22 | AC | 4 ms
3,916 KB |
testcase_23 | AC | 3 ms
3,844 KB |
testcase_24 | AC | 4 ms
5,728 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; }