結果

問題 No.866 レベルKの正方形
ユーザー fumofumofunifumofumofuni
提出日時 2023-07-01 20:05:02
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,445 bytes
コンパイル時間 2,700 ms
コンパイル使用メモリ 213,176 KB
実行使用メモリ 814,648 KB
最終ジャッジ日時 2023-09-22 14:14:15
合計ジャッジ時間 6,372 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 MLE -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}   
0