一直用的G++编译器,后来发现这道题我换C++编译器以后就能过了。。。
代码:
#include
#include
using namespace std;
int T;
int n, m;
int woc[52][52];
int main() {
cin >> T;
while (T--) {
int sum = 0;
cin >> n >> m;
memset(woc, 0, sizeof(woc));
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> woc[i][j];
if (woc[i][j]>0)
sum++;
}
}
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
for (int k = 1; k <= woc[i][j]; k++) {
if (woc[i - 1][j] < k)
sum++;
if (woc[i + 1][j] < k)
sum++;
if (woc[i][j - 1] < k)
sum++;
if (woc[i][j + 1] < k)
sum++;
}
}
}
cout << sum << endl;
}
system("pause");
}
题号hdu5538
链接:http://icpc.njust.edu.cn/Contest/6697/L/