ACM ICPC 2011-2012 Northeastern European Regional Contest(NEERC)A ASCII Area
2024-09-03 20:40:36
A:
给你一个矩阵求'/' 和 '\' 围成的图形,简单签到题,有一些细节要考虑。
题解:一行一行的跑,遇到'/'和'\' 就加0.5, 在面积里面的'.' 就加1.用一个flag来判断是否在围住的图形里面。
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <map>
#include <stack>
#include <set>
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
#define ms(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mp make_pair
#define eps 0.0000000001
#define IOS ios::sync_with_stdio(0);cin.tie(0);
const LL INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = +;
const int mod = 1e9+;
char s[maxn][maxn];
int main() {
#ifdef LOCAL
freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
#endif
// IOS freopen("ascii.in", "r", stdin);
freopen("ascii.out", "w", stdout); int h, w;
scanf("%d%d", &h, &w);
for(int i = ;i<h;i++) scanf("%s", s[i]); double ans = ;
for(int i = ;i<h;i++){
int flag = ;
for(int j = ;j<w;j++){
if((s[i][j]=='/'||s[i][j]=='\\')&&flag==){
flag = ;
ans += 0.5;
}
else if(s[i][j]=='.'&&flag){
ans+=1.0;
}
else if((s[i][j]=='/'||s[i][j]=='\\')&&flag){
flag = ;
ans += 0.5;
}
}
// printf("%.0f\n", ans);
}
printf("%.0f\n", ans);
return ;
}
最新文章
- C语言基础--函数
- struts2整合CKEditor和CKFinder实现上传
- file_get_content和curl的性能比较
- Java实现猜数游戏
- 如何下载到最新的版本的Oracle Database
- C语言学习的经典书籍--转载
- 转:JavaScript定时机制、以及浏览器渲染机制 浅谈
- 立贴读 《CLR》
- POJ 3122 &; 3258 &; 3273 #二分
- 依赖于boodtrap3的插件推荐以及bootrap发展前景
- [OC] UIcollectionView 与 UIcollectionViewCell 的使用
- java.lang.IllegalStateException: ApplicationEventMulticaster not initialized - call &#39;refresh&#39; before multicasting events via the context 错误
- glance系列一:glance基础
- Windows PowerShell 入門(9)-エラー編
- qsort例子
- 关于Linux一些问题和答案
- spring之继承配置
- 2018.11.06 洛谷P1099 树网的核(最短路+枚举)
- python测试开发django-42.auth模块登陆认证
- [转]servlet配置中init-param
热门文章
- DataFrame.to_dict(orient=&#39;dict&#39;)
- Jinja2 中文手册
- 浏览器给openresty连接发送参数请求,查询数据库,并返回json数据
- 20.AutoMapper 之理解你的映射(Understanding Your Mappings)
- SIP协议 会话发起协议(二)
- Linux-定时任务排查
- 006-saltstack之远程执行
- Linux中配置jdk环境变量出错:bad ELF interpreter: No such file or directory解决方法
- Android开发艺术探索笔记之Activity
- 费用流 Dijkstra 原始对偶方法(primal-dual method)