Codeforces Round #551 (Div. 2)
B. Serval and Toy Bricks
题意:
有一些规格相同的方块摆放在 n×m 的矩阵 h 中,h[i][j]代表第 (i,j) 个矩阵摆放的方块的高度;
现给你三个视图:
正视图:给出 m 个数据,第 i 个数据 f[ i ] 代表第 i 列方块的最大高度;
左视图:给出 n 个数据,第 i 个数据 l[ i ] 代表第 i 行方块的最大高度;
俯视图:给出 n×m 个数据,只有两个取值,第(i,j)个数据 top[ i ][ j ] 为0代表第(i,j)处无方块,为1代表有方块;
我的思路:
定义变量 a[ i ][ j ] 表示第 (i,j) 处摆放的方块的高度;
初始,根据正视图将 a[ i ][ j ] 填充满,就是假设每一列的高度全为f[ j ];
再根据左视图的值 l[ i ],将 a[][] 中第 i 行值 > l[i] 的赋为 l[ i ];
最后,根据 top[ i ][ j ]输出;
AC代码:
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define ll long long
const int maxn=; int n,m,h;
int a[maxn][maxn]; int main()
{
// freopen("C:\\Users\\hyacinthLJP\\Desktop\\in&&out\\contest","r",stdin);
scanf("%d%d%d",&n,&m,&h);
for(int i=;i <= m;++i)
{
int f;
scanf("%d",&f);
for(int j=;j <= n;++j)
a[j][i]=f;//将f填充进a[j][i]中
}
for(int i=;i <= n;++i)
{
int l;
scanf("%d",&l);
for(int j=;j <= m;++j)
a[i][j]=min(a[i][j],l);//修改a[i][j] > l的区域
}
for(int i=;i <= n;++i)
for(int j=;j <= m;++j)
{
int top;
scanf("%d",&top);
printf("%d%c",top ? a[i][j]:,j == m ? '\n':' ');//输出
} return ;
}
Codeforces Round #551 (Div. 2)的更多相关文章
- 【Codeforces】Codeforces Round #551 (Div. 2)
Codeforces Round #551 (Div. 2) 算是放弃颓废决定好好打比赛好好刷题的开始吧 A. Serval and Bus 处理每个巴士最早到站且大于t的时间 #include &l ...
- Codeforces Round #551 (Div. 2) 题解
CF1153A 直接做啊,分类讨论即可 #include<iostream> #include<string.h> #include<string> #includ ...
- Codeforces Round #551 (Div. 2) D. Serval and Rooted Tree (树形dp)
题目:http://codeforces.com/contest/1153/problem/D 题意:给你一棵树,每个节点有一个操作,0代表取子节点中最小的那个值,1代表取子节点中最大的值,叶子节点的 ...
- C. Serval and Parenthesis Sequence 【括号匹配】 Codeforces Round #551 (Div. 2)
冲鸭,去刷题:http://codeforces.com/contest/1153/problem/C C. Serval and Parenthesis Sequence time limit pe ...
- Codeforces Round #551 (Div. 2) E 二分 + 交互
https://codeforces.com/contest/1153/problem/E 题意 边长为n的正方形里面有一条蛇,每次可以询问一个矩形,然后会告诉你蛇身和矩形相交有几部分,你需要在最多2 ...
- Codeforces Round #551 (Div. 2) D 树形dp
https://codeforces.com/contest/1153/problem/D 题意 一颗有n个点的数,每个点a[i]为0代表取子节点的最小,1代表取最大,然后假设树上存在k个叶子,问你如 ...
- Codeforces Round #551 (Div. 2) D. Serval and Rooted Tree (树形dp)
题目链接 题意:给你一个有根树,假设有k个叶子节点,你可以给每个叶子节点编个号,要求编号不重复且在1-k以内.然后根据节点的max,minmax,minmax,min信息更新节点的值,要求根节点的值最 ...
- Codeforces Round #551 (Div. 2) EF Solution
E. Serval and Snake 对于一个矩形,如果蛇的一条边与它相交,就意味着这条蛇从矩形内穿到矩形外,或者从矩形外穿到矩形内.所以如果某个矩形的答案为偶数,意味着蛇的头尾在矩形的同一侧(内或 ...
- Codeforces Round #551 (Div. 2) A-E
A. Serval and Bus 算出每辆车会在什么时候上车, 取min即可 #include<cstdio> #include<algorithm> #include< ...
随机推荐
- Add In 简介(主要翻译于ESRI官方文档)
为ArcGIS桌面端建立Add In插件 平时以工作为主,有空时翻译一些文档,顺便练习英文,这个是因为用Add In来学习一下. 主要包括: 关于Add In 什么时候使用Add In Python ...
- Eclipse导出包含第三方Jar的工程
基于第三方开源的Jar包封装了一个工具类,在导出成Jar包后,引用新生成的Jar包,却报找不到类的错误.看了一下生成的Jar包,发现根本没有包含第三方Jar包的相关class.这是导出第三方Jar包时 ...
- android添加阴影
android底部增加背景 <?xml version="1.0" encoding="utf-8"?> <layer-list xmlns: ...
- jmeter使用TCP请求时,乱码问题,字符集设置
不墨迹,直接上干货.(提示:UTF-8一个汉字占3个字节) TCP请求默认发的是GBK字符集,要想修改成UTF-8,只需要修改bin目录下的jmeter.properties文件,其中tcp.char ...
- MyDAL - in && not in 条件 使用
索引: 目录索引 一.API 列表 C# 代码中 接口 IList.Contains() 方法生成 SQL 对应的 in(val1,val2,... ...) 如:.Queryer<Agent& ...
- python3 字符串/列表/元组(str/list/tuple)相互转换方法及join()函数的使用
在抓取网络数据的时候,有时会用正则对结构化的数据进行提取,比如 href="https://www.1234.com"等.python的re模块的findall()函数会返回一个所 ...
- timers模块
timers模块 var timers = require('timers'); function A() { //将A对象注册到定时器里 timers.enroll(); //进行激活,如果不激活, ...
- 用Redis管理Session
maven <dependency> <groupId>redis.clients</groupId> <artifactId>jedis</ar ...
- Elastic Stack-Elasticsearch使用介绍(五)
一.前言 前4篇将Elasticsearch用法的API和原理方面东西介绍了一下,相信大家对Elasticsearch有了一定的认知,接下我们主要从索引的建立到后期的一些优化做一些介绍: 二. ...
- Fire Again CodeForces - 35C (BFS)
After a terrifying forest fire in Berland a forest rebirth program was carried out. Due to it N rows ...