結果
問題 | No.866 レベルKの正方形 |
ユーザー | Cinnamoroll |
提出日時 | 2019-08-16 22:53:46 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 1,912 ms / 6,000 ms |
コード長 | 5,973 bytes |
コンパイル時間 | 1,721 ms |
コンパイル使用メモリ | 172,104 KB |
実行使用メモリ | 414,108 KB |
最終ジャッジ日時 | 2023-10-24 03:20:45 |
合計ジャッジ時間 | 26,454 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,656 KB |
testcase_01 | AC | 2 ms
5,656 KB |
testcase_02 | AC | 2 ms
5,656 KB |
testcase_03 | AC | 2 ms
5,656 KB |
testcase_04 | AC | 2 ms
5,656 KB |
testcase_05 | AC | 3 ms
5,656 KB |
testcase_06 | AC | 3 ms
5,656 KB |
testcase_07 | AC | 2 ms
5,656 KB |
testcase_08 | AC | 1,615 ms
414,104 KB |
testcase_09 | AC | 1,739 ms
414,108 KB |
testcase_10 | AC | 1,857 ms
414,108 KB |
testcase_11 | AC | 1,912 ms
414,108 KB |
testcase_12 | AC | 1,501 ms
414,108 KB |
testcase_13 | AC | 1,855 ms
414,108 KB |
testcase_14 | AC | 1,387 ms
414,108 KB |
testcase_15 | AC | 1,850 ms
414,108 KB |
testcase_16 | AC | 1,814 ms
414,108 KB |
testcase_17 | AC | 1,839 ms
414,108 KB |
testcase_18 | AC | 1,851 ms
414,108 KB |
testcase_19 | AC | 1,267 ms
414,108 KB |
testcase_20 | AC | 1,093 ms
414,108 KB |
testcase_21 | AC | 1,355 ms
414,104 KB |
testcase_22 | AC | 3 ms
5,652 KB |
testcase_23 | AC | 3 ms
5,652 KB |
testcase_24 | AC | 3 ms
7,712 KB |
ソースコード
// warm heart, wagging tail,and a smile just for you! // // ▒█████▒▒ // ██████████▒ // ▒████████████▒ // ██████████████████ // ████████████████████▒ // ▒██████████████████████▒ // ▒███████████████████████ // ▒████▒▒▒▒▒▒█████████████████▒ // ███▒▒▒▒▒▒██████████████████████▒▒▒ // ▒██▒▒███████████████████████▒▒▒▒▒██████ // ▒█████████████████████████▒▒▒▒▒▒█████████▒ // ▒█████████████████████▒▒▒▒▒▒██████████████ // ▒████ ████▒▒▒▒▒████ ████▒ // ▒█████▒ ████ ▒▒▒▒███████ ████ ██████▒ // ▒██▒▒▒▒▒ ██████ █████████ ██████ ██▒▒▒██▒ // █████████ ████████ █████████ ████████ ▒▒▒▒█████ // ▒█████████ ██████ ████████▒ ██████ █████████ // ▒██████████ ████ █████▒▒▒▒▒▒ ████ ██████████ // ████████████ ▒▒▒▒▒▒▒████████ ███████████▒ // ▒██████████▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒███████████████████████████████████▒ // ███▒▒▒▒▒▒▒▒▒▒▒▒█████████████████████████████████████████▒▒████████▒ // ▒▒▒▒▒▒▒▒▒██████████████ ███████▒▒▒▒███████████ // █████████████████████████ ███████▒▒▒██████████████▒ // █████████████████████████████ ███████▒▒▒██████████████████▒ // ██████████████████████████████████████████████████████████████████████ // ██████████████████████████████████████████████████████████████████▒ // ▒█████████████████▒▒▒▒▒▒▒██████████████████████████████████▒▒▒ // #include "bits/stdc++.h" using namespace std; #define MOD 1000000007 //#define MOD 998244353 const double EPS = 1e-9; #define INF (1LL<<60) #define D double #define fs first #define sc second //#define int long long #define FOR(i,a,b) for(int i=(a);i<(b);++i) #define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i) #define REP(i,n) FOR(i,0,(n)) #define RREP(i,n) RFOR(i,0,(n)) #define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr) #define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr) #define range(i,a,b) ((a)<=(i) && (i)<(b)) #define debug(x) cout << #x << " = " << (x) << endl; #define SP << " " << typedef pair<int,int> P; typedef vector<int> vec; typedef vector<vector<int>> mat; int cnt[2001][2001][26] = {}; int h,w,x; bool check(int u, int v, int mid, bool up){ if(u+mid > h || v+mid > w) return false; vec tmp(26,0); REP(i,26) tmp[i] = cnt[u+mid][v+mid][i]+cnt[u][v][i]-cnt[u+mid][v][i]-cnt[u][v+mid][i]; int sum = 0; REP(i,26) if(tmp[i]) sum++; //debug(sum); if(up) return x >= sum; else return x > sum; } signed main(){ ios::sync_with_stdio(false); cin.tie(0); cin >> h >> w >> x; vector<string> s(h); REP(i,h) cin >> s[i]; REP(i,h) REP(j,w) cnt[i+1][j+1][s[i][j]-'a']++; REP(i,h) REP(j,w+1) REP(k,26) cnt[i+1][j][k] += cnt[i][j][k]; REP(i,h+1) REP(j,w) REP(k,26) cnt[i][j+1][k] += cnt[i][j][k]; long long ans = 0; // REP(i,h) REP(j,w){ // int id = min(h-i,w-j)+1; // int ng = 0, ok = id; // while (abs(ng-ok)>1) { // int mid = (ng+ok)/2; // (check(i,j,mid,true)?ok:ng) = mid; // } // int ng2 = 0, ok2 = id; // while (abs(ng2-ok2)>1) { // int mid = (ng2+ok2)/2; // (check(i,j,mid,false)?ok2:ng2) = mid; // } // ans += ok-ok2; // //cout << i SP j SP ok SP ok2 << endl; // } for(int v = -h+1; v < w; v++){ int j = max(0,v), l = 1, r = 1; FOR(i,h-min(h,h+v),h){ // cout << i SP j << endl; while(check(i,j,l,false)) l++; while(check(i,j,r,true)) r++; ans += r-l; r--; l--; j++; } } cout << ans << endl; return 0; }