您的位置:首页 > 其它

UVA1641 - ASCII Area

2015-10-07 19:39 106 查看
其实思路很简单的。。一行一行的扫,在两个/ \之间的点就是黑色要求的

#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
using namespace std;
const int INF = ~0U >> 1;
const int maxn = 100+5;
int m, n;
char str[maxn][maxn];

int main()
{
while(scanf("%d%d", &m, &n) != EOF) {
int ans = 0;
double cnt = 0;
for(int i = 0; i < m; ++i) {
scanf("%s", str[i]);
for(int j = 0; j < n; ++j)
if(str[i][j] == '/' || str[i][j] == '\\') cnt += 0.5;
}
for(int i = 0; i < m; ++i) {
bool ok = false;
for(int j = 0; j < n; ++j) {
if(str[i][j] == '/' || str[i][j] == '\\') ok = !ok;
if(ok && str[i][j] == '.') ++ans;
}
}
cout << (double)ans + cnt << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: