Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<memory.h>
- #include<bits/stdc++.h>
- using namespace std;
- int arr[21][21];
- int N, M;
- int oper(int k) {
- return (k*k) + (k - 1)*(k - 1);
- }
- int main() {
- int T;
- scanf("%d", &T);
- for (int test = 1; test <= T; test++) {
- memset(arr, 0, sizeof(arr));
- scanf("%d %d", &N, &M);
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < N; j++) {
- scanf("%d", &arr[i][j]);
- }
- }
- int cnt;
- int maxnum = -1;
- int ans = -1;
- for (int i = 0; i < N; i++) {
- for (int j = 0; j < N; j++) {
- for (int k = 1; k <= 2 * N; k++) {
- cnt = 0;
- for (int y = 0; y < N; y++) {
- for (int x = 0; x < N; x++) {
- //집 개수
- if (arr[y][x] == 1 && abs(i - y) + abs(j - x) < k) {
- cnt++;
- }
- }
- }
- if (cnt*M >= oper(k) && ans < cnt) {
- ans = cnt;
- }
- }
- }
- }
- printf("#%d %d\n",test,ans);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement