Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- #define ll long long
- #define ii pair<ll, ll>
- #define vi vector<ll>
- #define vii vector<ii>
- #define each(x) for(auto it = x.begin(); it != x.end(); it++)
- #define gc() getchar_unlocked()
- #define pc(x) putchar_unlocked(x)
- #define DEBUG
- #ifdef DEBUG
- #define debug(x) cout << #x << " = " << x << endl
- #else
- #define debug(x) ;
- #endif
- using namespace std;
- int mat[305][305];
- int R, C, K;
- int roll(int arr[], int siz) {
- int left = 0, right = 0, cur_sum = 0, min_area = 10000;
- while(right < siz) {
- while(cur_sum < K && right < siz) {
- cur_sum += arr[right++];
- }
- while(cur_sum >= K) {
- min_area = min(min_area, right - left);
- cur_sum -= arr[left++];
- }
- }
- return (min_area == 10000) ? -1 : min_area;
- }
- void scan_int(int &x);
- int main() {
- ios_base::sync_with_stdio(false);
- while(1) {
- scan_int(R);
- scan_int(C);
- scan_int(K);
- if(!(R | C | K)) {
- break;
- }
- memset(mat, 0, sizeof(mat));
- for(int i = 0; i < R; i++) {
- for(int j = 0; j < C; j++) {
- char c;
- c = gc();
- mat[i][j] = c == '.';
- }
- gc();
- }
- int best = 100000000;
- int tmp[305];
- for(int i = 0; i < R; i++) {
- memset(tmp, 0, sizeof(tmp));
- for(int j = i; j < R; j++) {
- for(int k = 0; k < C; k++) {
- tmp[k] += mat[j][k];
- }
- int it = roll(tmp, C);
- if(it != -1) {
- best = min(best, it * ((j - i) + 1));
- }
- }
- }
- printf("%d", best);
- pc('\n');
- }
- return 0;
- }
- void scan_int(int &x) {
- register int c = gc();
- x = 0;
- while(c < 48 || c > 57) {
- c = gc();
- }
- for(; c > 47 && c < 58; c = gc()) {
- x = (x << 1) + (x << 3) + c - 48;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement