Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
121482 吴悠 封闭面积问题 C++ 解答错误 0 0 MS 284 KB 884 2024-01-21 20:40:41

Tests(0/10):


#include<iostream> #include<queue> using namespace std; int dx[4]={1,-1,0,0}; int dy[4]={0,0,-1,1}; bool a[11][11]; struct Node{ int x; int y; }; queue<Node> q; void bfs(int tx,int ty){ Node start={tx,ty}; q.push(start); while(q.empty()==false){ Node front=q.front(); a[front.x][front.y]=1; q.pop(); for(int i=0;i<4;i++){ int xx=front.x+dx[i]; int yy=front.y+dy[i]; if(((xx>0 && xx<=10) && (yy>0 && yy<=10)) && a[xx][yy]==0){ Node node={xx,yy}; q.push(node); } } } } int main(){ int s; for(int i=1;i<=10;i++){ for(int j=1;j<=10;j++){ cin>>a[i][j]; } } for(int i=1;i<=10;i++){ for(int j=1;j<=10;j++){ if(i==1 || j==1 || i==10 || j==10){ bfs(i,j); } } } for(int i=1;i<=10;i++){ for(int j=1;j<=10;j++){ if(a[i][j]==0){ s++; } } } cout<<s<<endl; return 0; }


测评信息: