洛谷CSP-J模擬題P8546 小挖的 X 獻(xiàn)身求解
#include<bits/stdc++.h>
using namespace std;
int main()
{
? ? int n,ci=0;
? ? char a[105][105];
? ? cin>>n;
? ? for(int i=1;i<=n;i++)
? ? {
? ? ? ? for(int j=1;j<=n;j++)
? ? ? ? {
? ? ? ? ? ? cin>>a[i][j];
? ? ? ? }
? ? }
? ? for(int i=1;i<=n;i++)
? ? {
? ? ? ? for(int j=1;j<=n;j++)
? ? ? ? {
? ? ? ? ? ? if(a[i][j]=='1')
? ? ? ? ? ? {
? ? ? ? ? ? int s=1;
? ? ? ? ? ? while(a[i+s][j+s]=='1')
? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? s++;
? ? ? ? ? ? }
? ? ? ? ? ? int r=j+s-1;
? ? ? ? ? ? if(a[i][r]=='1')
? ? ? ? ? ? {
? ? ? ? ? ? for(int d=1;d<s;d++)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? if(a[i+d][j+s-1-d]=='0')
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? break;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? if(d==s-1)
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ci++;
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }?
? ? ? ? ? ? }?
? ? ? ? ? ? }
? ? ? ? }
? ? }
? ? cout<<ci;
? ? return 0;
}?