记录编号 121354 评测结果 AAAAAAA
题目名称 [USACO]家的范围 最终得分 100
用户昵称 GravatarHouJikan 是否通过 通过
代码语言 C++ 运行时间 0.018 s
提交时间 2014-09-19 16:07:11 内存使用 0.57 MiB
显示代码纯文本
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <list>
#include <iterator>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <functional>
#include <deque>
#define For(i,j,k) for(int i=(j);i<=(k);i++)
using namespace std;
typedef long long LL;
typedef unsigned int Uint;
const int INF=0x7ffffff;
//================struct declaration======================

//================var declaration=========================
const int MAXN=260;
int S[MAXN][MAXN];
int n,len;
//================function declaration====================

//================main code===============================
using namespace std;
int main()
{
  string ProgrammeName="range";
  string FloderName="COGS";
  freopen((ProgrammeName+".in").c_str(),"r",stdin);
  freopen((ProgrammeName+".out").c_str(),"w",stdout);
#ifdef DEBUG
  clock_t Start_Time=clock();
  system(("copy C:\\Users\\abc\\Desktop\\HouJikan\\"+FloderName+"\\standard.cpp C:\\Users\\abc\\Desktop\\HouJikan\\"+FloderName+"\\submit.txt").c_str());
#endif
  scanf("%d",&n);
  char ch;
  memset(S,0,sizeof(S));
  For(i,1,n)
  {
    getchar();
    For(j,1,n)
    {
      ch=getchar();
      while (ch!='1'&&ch!='0')
        ch=getchar();
      if (ch=='1')
        S[i][j]=0;
      else if (ch=='0')
        S[i][j]=1;
      S[i][j]+=S[i-1][j]+S[i][j-1]-S[i-1][j-1];
    } 
  }
  for(len=2;len<=n;len++)
  {
    int ans=0;
    For(i,len,n)
      For(j,len,n)
        if (S[i][j]-S[i-len][j]-S[i][j-len]+S[i-len][j-len]==0)
          ans++;
    if (ans!=0)
      printf("%d %d\n",len,ans);
    else
      return 0;
  }
#ifdef DEBUG
  clock_t End_Time=clock();
  printf("\n\nTime Used :%.6lf Ms\n",double(Start_Time-End_Time)/(-CLOCKS_PER_SEC));
#endif
  return 0;
}
//================function code===========================