#include <bits/stdc++.h>
using namespace std;
int n;
int res[2];
int board[150][150];
bool check(int x,int y,int n) {
for(int i=x;i<x+n; i++){
for(int j=y; j<y+n;j++) {
if(board[x][y]!=board[i][j]) return false;
}
}
return true;
}
void paper(int x,int y,int n) {
if(check(x,y,n)) {
res[board[x][y]]++;
return;
}
n/=2;
for(int i=0; i<2; i++){
for(int j=0; j<2; j++) {
paper(x+i*n,y+j*n,n);
}
}
}
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n;
for(int i=0; i<n; i++) {
for(int j=0; j<n; j++){
cin >> board[i][j];
}
}
paper(0,0,n);
for(int i=0; i<2; i++) cout << res[i] << '\n';
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: