题解 | #科学家的模型#
科学家的模型
https://ac.nowcoder.com/acm/contest/11175/A
将 矩阵上下左右各拓宽
个单位。
统计每一个 字符周围的
是否为三个。
最后 字码不存在这样的
字符
字码存在一个
字码存在两个
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
typedef double db;
#define fi first
#define se second
int m[8][8];
inline int around(int x, int y){
return m[x-1][y]+m[x][y-1]+m[x+1][y]+m[x][y+1];
}
inline int ans(){
int res=0;
for(int i=1;i<=5;++i)
for(int j=1;j<=5;++j)
if(m[i][j]==1&&around(i, j)==3)
++res;
if(res==0) return 0;
else if(res==1) return 9;
else return 8;
}
inline int read01(){
char c=0;
while(c!='0'&&c!='1') cin>>c;
return c=='1';
}
int main(){
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
for(int i=1;i<=5;++i)
for(int j=1;j<=5;++j)
m[i][j]=read01();
cout<<ans();
cout.flush();
return 0;
}
查看10道真题和解析
深信服公司福利 731人发布