1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
| #include <stdio.h> #include <vector> using namespace std; int map[100][100]; int N; vector<vector<vector<int>>> b = {{{1,1,1,1}},{{1},{1},{1},{1}}, {{1,1,0},{0,1,1}},{{0,1},{1,1},{1,0}}, {{1,1},{1,1}}, {{1,1,1},{0,0,1}},{{1,0,0,},{1,1,1}},{{0,1},{0,1},{1,1}},{{1,1},{1,0},{1,0}}, {{1,1,1},{0,1,0}},{{1,0},{1,1},{1,0}},{{0,1,0},{1,1,1}},{{0,1},{1,1},{0,1}}}; int main() { scanf("%d", &N); int ans, tc = 0; while (N) { ans = -4000001; for (int i = 0; i < N; ++i) for (int j = 0; j < N; ++j) scanf("%d", &map[i][j]); for (int rep = 0; rep < 13; ++rep) { for (int i = 0; i <= N - b[rep].size(); ++i) for (int j = 0; j <= N - b[rep][0].size(); ++j) { int cur = 0; for (int by = 0; by < b[rep].size(); ++by) for (int bx = 0; bx < b[rep][0].size(); ++bx) { if (b[rep][by][bx]) { cur += map[i + by][j + bx]; } } ans = ans > cur ? ans : cur; } } printf("%d. %d\n", ++tc, ans); scanf("%d", &N); } }
|