Created
September 25, 2008 01:16
-
-
Save dazza/12723 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <fstream> | |
using namespace std; | |
int square[250][250]; | |
int ncount[251]; | |
int min_tri(int i, int j , int k) | |
{ | |
int temp = min(i,j); | |
return min(temp,k); | |
} | |
int main() | |
{ | |
ifstream fin("range.in"); | |
ofstream fout("range.out"); | |
int N ; | |
fin>>N; | |
char ignore = fin.get();; | |
for (int i = 0 ; i<N; i++) | |
{ | |
for (int j=0; j<N; j++ ) | |
{ | |
square[i][j] = fin.get()-'0'; | |
} | |
ignore = fin.get(); | |
} | |
//dp | |
for (int i =N-2 ; i>=0 ;i--) | |
{ | |
for (int j = N-2 ;j>=0 ; j--) | |
{ | |
if (square[i][j]) | |
{ | |
square[i][j] = min_tri(square[i+1][j], | |
square[i][j+1],square[i+1][j+1])+1; | |
for (int k = 2; k<=square[i][j]; k++) | |
{ | |
ncount[k]++; | |
} | |
} | |
} | |
} | |
//output | |
for (int k = 2 ; k<=251 ; k++) | |
{ | |
if (ncount[k]) | |
{ | |
fout<<k<<' '<<ncount[k]<<endl; | |
} | |
} | |
fin.close(); | |
fout.close(); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment