#include #include #include #include #include #include using namespace std; // #define int short #define endl "\n" const long long INF = (long long)1e18; const long long MOD = (long long)1e9 + 7; string yn(bool f){return f?"Yes":"No";} string YN(bool f){return f?"YES":"NO";} const int NUM = 26; int H, W, K; int check(vector>> & con, int y, int x, int sz){ int level = 0; sz--; if(sz < 0) return 0; if(sz + y >= H || sz + x >= W) return NUM+1; int y2 = y + sz, x2 = x + sz; for(int i = 0; i < NUM; i++){ int sum = con[y2+1][x2+1][i] - con[y2+1][x][i] - con[y][x2+1][i] + con[y][x][i]; level += !!sum; } return level; } signed main(){ cin.tie(0); ios::sync_with_stdio(false); cout< squares; vector>> con; cin>>H>>W>>K; con.resize(H+2, vector>(W+2, vector(NUM, 0))); squares.resize(H); for(int i = 0; i < H; i++){ cin>>squares[i]; for(int j = 0; j < W; j++){ con[i+1][j+1][squares[i][j] - 'a']++; } } for(int k = 0; k < NUM; k++){ for(int i = 0; i <= H; i++){ for(int j = 0; j <= W; j++){ con[i][j+1][k] += con[i][j][k]; } } } for(int k = 0; k < NUM; k++){ for(int i = 0; i <= H; i++){ for(int j = 0; j <= W; j++){ con[i+1][j][k] += con[i][j][k]; } } } // while(true){ // int a, b, c; // cin>>a>>b>>c; // cout< K){ h = m; } else { l = m; } } a = h; h = min(H-i, W-j) + 1, l = 0; while(l + 1 < h){ m = (l + h)/2; if(!(check(con,i,j,m) < K)){ h = m; } else { l = m; } } b = l; // cout<<"i = "<