Submission #477861

# Submission time Handle Problem Language Result Execution time Memory
477861 2021-10-04T08:45:40 Z BThero Orchard (NOI14_orchard) C++17
4 / 25
1000 ms 8136 KB
#include <bits/stdc++.h>

#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()

using namespace std;

typedef long long ll;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<int>> a(n, vector<int>(m, 0));

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}

	int ans = (int)1e9;

	for (int x1 = 0; x1 < n; x1++) {
		for (int y1 = 0; y1 < m; y1++) {
			for (int x2 = x1; x2 < n; x2++) {
				for (int y2 = y1; y2 < m; y2++) {
					int cnt = 0;

					for (int x = 0; x < n; x++) {
						for (int y = 0; y < m; y++) {
							if (x1 <= x && x <= x2 && y1 <= y && y <= y2) {
								cnt += (a[x][y] == 0);
							}
							else {
								cnt += (a[x][y] == 1);
							}
						}
					}

					ans = min(ans, cnt);
				}
			}
		}
	}

	cout << ans << '\n';
	return 0;
}

# Verdict Execution time Memory Grader output
1 Correct 1 ms 208 KB Output is correct
2 Correct 0 ms 208 KB Output is correct
3 Correct 0 ms 208 KB Output is correct
4 Correct 0 ms 208 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 452 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 8136 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1076 ms 1488 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1096 ms 336 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 1090 ms 4664 KB Time limit exceeded
2 Halted 0 ms 0 KB -