hihoCoder Challenge 27 register

Ended

Participants:323

Verdict:Accepted
Submitted:2017-02-19 19:15:42

Lang:G++

Edit
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
#include<bits/stdc++.h>
using namespace std;
const int maxn=1010;
int a[maxn][maxn],b[maxn][maxn],c[maxn][maxn];
int n;
int sum(int a[maxn][maxn],int x1,int y1,int x2,int y2){
    return a[x2][y2]-a[x1-1][y2]-a[x2][y1-1]+a[x1-1][y1-1];
}
bool allone(int a[maxn][maxn],int x1,int y1,int x2,int y2){
    return sum(a,x1,y1,x2,y2)==(x2-x1+1)*(y2-y1+1);
}
bool check(int x,int y,int k){
    if(!allone(b,x,y,x+k-1,y+k-2))
        return false;
    if(!allone(c,x,y,x+k-2,y+k-1))
        return false;
    return true;
}
bool check(int k){
    if(k==1)return true;
    for(int i=1;i+k-1<=n;i++){
        for(int j=1;j+k-1<=n;j++){
            if(check(i,j,k))
                return true;
        }
    }
    return false;
}
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX