题意:

就是用一个字符矩阵代表一个闭合的阴影部分,然后求阴影部分的面积。

分析:

一个'/'和'\'字符都代表半个小方块的面积。

关键就是判断'.'是否属于阴影部分,这才是本题的关键。

从第一列开始,从上到下扫面'/'和'\'字符的个数,如果是奇数,则'.'属于阴影部分,阴影面积加一。

 #include <cstdio>

 const int maxn =  + ;
char map[maxn][maxn]; int main()
{
//freopen("in.txt", "r", stdin);
int h, w;
while(scanf("%d%d", &h, &w) == )
{
for(int i = ; i < h; ++i) scanf("%s", map[i]);
int cnt = ;
bool flag = false;
for(int i = ; i < w; ++i)
for(int j = ; j < h; ++j)
{
if(map[j][i] == '/' || map[j][i] == '\\')
{
cnt++;
flag = !flag;
}
else if(flag) cnt += ;
} printf("%d\n", cnt / );
} return ;
}

代码君

UVa 1641 ASCII Area的更多相关文章

  1. UVa 1641 ASCII Area (计算几何,水题)

    题意:给定一个矩阵,里面有一个多边形,求多边形的面积. 析:因为是在格子里,并且这个多边形是很规则的,所以所有格子不是全属于多边形就是全不属于,或者一半,并且我们可以根据"/"和“ ...

  2. ACM ICPC 2011-2012 Northeastern European Regional Contest(NEERC)A ASCII Area

    A: 给你一个矩阵求'/' 和 '\' 围成的图形,简单签到题,有一些细节要考虑. 题解:一行一行的跑,遇到'/'和'\' 就加0.5, 在面积里面的'.' 就加1.用一个flag来判断是否在围住的图 ...

  3. 紫书 例题 10-24 UVa 1641(面积计算)

    遍历一遍,遇到边界为奇数次时,格子在多边形内 偶数次时,在多边形外 #include<cstdio> #define REP(i, a, b) for(int i = (a); i < ...

  4. [UVA Live 12931 Common Area]扫描线

    题意:判断两个多边形是否有面积大于0的公共部分 思路:扫描线基础. #pragma comment(linker, "/STACK:10240000") #include < ...

  5. EOJ 1641/UVa The SetStack Computer

    Background from Wikipedia: “Set theory is a branch of mathematics created principally by the German ...

  6. UVA 10522 Height to Area(知三角形三高求面积)

    思路:海伦公式, AC代码: #include<bits/stdc++.h> using namespace std; int main() { int n; scanf("%d ...

  7. UVa 109 - SCUD Busters(凸包计算)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  8. uva 11178 - Morley's Theorem

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

  9. UVA 1456 六 Cellular Network

    Cellular Network Time Limit:3000MS     Memory Limit:0KB     64bit IO Format:%lld & %llu Submit S ...

随机推荐

  1. 关于B/S系统在移动端应用的一些注意的地方(不断更新)

    1.不要直接把PC端的页面直接搬到移动端来用.这里举个例子:有个活动页面,在PC端和手机端的Safari里展现都好,但是当用手机APP(如手机淘宝)扫码打开后,却没法顺畅的异步获取到jsonp的信息. ...

  2. The content of element type "sqlMapConfig" is incomplete,

    The content of element type "sqlMapConfig" is incomplete, it must match "(properties? ...

  3. wpf 实现全屏与取消全屏

    /// <summary> /// 全屏 /// </summary> public void ToFullscreen() { //存储窗体信息 m_WindowState ...

  4. 转:深入学习Oracle分区表及分区索引

    转自:http://database.ctocio.com.cn/tips/286/8104286.shtml 关于分区表和分区索引(About Partitioned Tables and Inde ...

  5. eclipse里maven项目An error occurred while filtering resources解决办法(转载)

    转自:http://liyanjie918.blog.163.com/blog/static/20227290201581143110105/ 在使用eclipse构建maven项目时,突然出现错误提 ...

  6. 在Hadoop分布式文件系统的索引和搜索

    FROM:http://www.drdobbs.com/parallel/indexing-and-searching-on-a-hadoop-distr/226300241?pgno=3 在今天的信 ...

  7. Gnome 插件介绍

    插件:Applications Menuhttps://extensions.gnome.org/extension/6/applications-menu/ TopIconshttps://exte ...

  8. arguments.callee查询调用b函数的是哪个函数

    // function functionname(){ // function b(){ // console.log(arguments.callee.caller.name); // } // b ...

  9. 免费素材:25套免费的 Web UI 设计的界面元素(转)

    Web 元素是任何网站相关项目都需要的,质量和良好设计的元素对于设计师来说就像宝贝一样.如果您正在为您的网站,博客,Web 应用程序或移动应用程序寻找完美设计的网页元素,那么下面这个列表会是你需要的. ...

  10. MySQL分区表(转)

    查看分区情况 SELECT * FROM information_schema.PARTITIONS WHERE table_name='table_name': PARTITION_NAME:分区的 ...