Run ID | 作者 | 问题 | 语言 | 测评结果 | 分数 | 时间 | 内存 | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|---|
121541 | 梁乃元 | 封闭面积问题 | C++ | 内存超限 | 0 | 106 MS | 131312 KB | 999 | 2024-01-21 22:31:24 |
#include <bits/stdc++.h> using namespace std; int a [32] [32] , b [32] [32] ; int dx [5] = { 0 , -1 , 1 , 0 , 0 } ; int dy [5] = { 0 , 0 , 0 , -1 , 1 } ; int n , sum = 0 ; void dfs ( int x , int y ) { if ( x < 0 || x > n + 1 || y < 0 || y > n + 1 || a [x] [y] == 2 ) { return ; } a [x] [y] = 1 ; int a = 4 ; while ( a -- ) { dfs ( x + dx [a] , y + dy [a] ) ; } return ; } int main ( ) { for ( int i = 1 ; i <= 10 ; i ++ ) for ( int j = 1 ; j <= 10 ; j ++ ) { cin >> b [i] [j] ; if ( ! b [i] [j] ) { a [i] [j] = 0 ; } else { a [i] [j] = 2 ; } } dfs ( 0 , 0 ) ; cout << endl ; for ( int i = 1 ; i <= 10 ; i ++ ) { for ( int j = 1 ; j <= 10 ; j ++ ) { if ( a [i] [j] ) { cout << "X " ; sum ++ ; } else { cout << a [i] [j] << ' ' ; } } cout << endl ; } cout << sum << endl ; return 0 ; }