結果
問題 | No.866 レベルKの正方形 |
ユーザー |
|
提出日時 | 2023-07-01 20:05:02 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,445 bytes |
コンパイル時間 | 2,415 ms |
コンパイル使用メモリ | 207,780 KB |
最終ジャッジ日時 | 2025-02-15 05:29:04 |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | -- * 3 |
other | AC * 2 WA * 6 MLE * 1 -- * 13 |
ソースコード
#include<bits/stdc++.h>using namespace std;//#pragma GCC optimize("Ofast")#define rep(i,n) for(ll i=0;i<n;i++)#define repl(i,l,r) for(ll i=(l);i<(r);i++)#define per(i,n) for(ll i=(n)-1;i>=0;i--)#define perl(i,r,l) for(ll i=r-1;i>=l;i--)#define fi first#define se second#define pb push_back#define ins insert#define pqueue(x) priority_queue<x,vector<x>,greater<x>>#define all(x) (x).begin(),(x).end()#define CST(x) cout<<fixed<<setprecision(x)#define vtpl(x,y,z) vector<tuple<x,y,z>>#define rev(x) reverse(x);using ll=long long;using vl=vector<ll>;using vvl=vector<vector<ll>>;using pl=pair<ll,ll>;using vpl=vector<pl>;using vvpl=vector<vpl>;const ll MOD=1000000007;const ll MOD9=998244353;const int inf=1e9+10;const ll INF=4e18;const ll dy[9]={1,0,-1,0,1,1,-1,-1,0};const ll dx[9]={0,1,0,-1,1,-1,1,-1,0};template<class T> inline bool chmin(T& a, T b) {if (a >= b) {a = b;return true;}return false;}template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}ll sdx[3]={1,0,1};ll sdy[3]={0,1,1};int main(){ll h,w,z;cin >> h >> w >> z;vector<string> g(h);rep(i,h)cin >> g[i];vector<vvl> dp(26,vvl(h,vl(w,INF)));rep(k,26){per(i,h){per(j,w){rep(f,3){ll nx=i+sdx[f],ny=j+sdy[f];if(nx>=h||ny>=w)continue;if(dp[k][nx][ny]==INF)continue;ll to=dp[k][nx][ny]+1;if(i+to<=h&&j+to<=w){chmin(dp[k][i][j],dp[k][nx][ny]+1);}}if(g[i][j]==char('a'+k))dp[k][i][j]=1;}}}/*rep(i,h){rep(j,w)cout << dp[3][i][j] <<" ";cout << endl;}*/ll ans=0;rep(i,h){rep(j,w){vl cand={0};cand.emplace_back(min(h-i,w-j)+1);rep(k,26){if(dp[k][i][j]!=INF)cand.emplace_back(dp[k][i][j]);}sort(all(cand));/*if(i==0&&j==0){for(auto p:cand)cout << p <<" ";cout << endl;}*///cout << cand.size() << endl;if(cand.size()>z+1){ans+=cand[z+1]-cand[z];cout << i <<" " << j <<" " << cand[z+1]-cand[z] << endl;}}}cout << ans << endl;}