Gym - 101670E Forest Picture (CTU Open Contest 2017 模拟)
题目:
https://cn.vjudge.net/problem/1451310/origin
题意&思路:
纯粹模拟。
大体题意是这样的:
1、有人要在一个10-9<=x<=109,10-9<=y<=109,这么大的一张纸上去画图,而我们只需要打印输出最大为0<=x<=100,0<=y<=100范围内的图案就ok了。
2、如果s==0的话就在给出的坐标处画一个“_o_”( ASCII codes 95, 111, 95)的图案,表示a tree stump。
3、如果s>0的话,就在给出的坐标处画一个高度为s的a standing tree,这个standing tree 首先有一个root图案为:“_|_”,(ASCII codes 95, 124, 95),然后有s个“|”表示树干,最后在最高的树干上边的一个单元格中画一个“^” ASCII code 94)。
4、另一个需要注意的地方是,题目中的坐标表示为左下角为(0,0),右上角是(m-1,m-1),需要做一下下标的变换对应到数组中。
代码:
#include <bits/stdc++.h>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
const int maxn = ;
int mp[maxn][maxn];
int n,m; void Dn(int x,int y,int id){
if(x>= && x<m && y>= && y<m){//必须是在要输出的范围内才能画上图案
mp[x][y] = id;
}
return;
} void print(){
for(int i = ; i<m+; i++){
printf("*");
}
printf("\n");
for(int i = ; i<m; i++){
for(int j = ; j<m; j++){
if(j==)printf("*");
printf("%c",mp[i][j]);
if(j==m-)
printf("*\n");
}
}
for(int i = ; i<m+; i++){
printf("*");
}
printf("\n\n");
} int main(){
while(scanf("%d%d",&m,&n)!=EOF){
for(int i = ; i<m; i++){
for(int j = ; j<m; j++){
mp[i][j] = ;
}
}
int x,y,s;
for(int kk = ; kk<n; kk++){
scanf("%d%d%d",&s,&y,&x);//注意行和列的输入位置
x = m-x-;//由题意的坐标变换到数组中的下标中
if(s==){
Dn(x,y,);//打印'o'
Dn(x,y-,);//打印'_'
Dn(x,y+,);//打印'_'
}
else if(s>){
Dn(x,y,);//打印'|'
Dn(x,y-,);//打印'_'
Dn(x,y+,);//打印'_'
for(int i=; i<=s; i++){
Dn(x-i,y,);//打印'|'
Dn(x-i,y-,);//打印'/'
Dn(x-i,y+,);//打印'\'
}
Dn(x-s-,y,);//打印'^'
}
}
print();
}
return ;
}
Gym - 101670E Forest Picture (CTU Open Contest 2017 模拟)的更多相关文章
- Gym - 101670H Go Northwest!(CTU Open Contest 2017 思维题+map)
题目: Go Northwest! is a game usually played in the park main hall when occasional rainy weather disco ...
- Gym - 101670A Amusement Anticipation(CTU Open Contest 2017 签到题)
题目&题意: 倒着找处于最后位置的等差数列的开头的位置. 例: 1 5 3 4 5 6 3 4 5 6是等差数列,它的开头的位置是3 PS: 读题真的很重要!!!!多组输入,上来就读错了!! ...
- Gym - 101670F Shooting Gallery(CTU Open Contest 2017 区间dp)
题目&题意:(有点难读...) 给出一个数字序列,找出一个区间,当删除这个区间中的两个相同的数字后,只保留这两个数字之间的序列,然后继续删除相同的数字,问最多可以实行多少次删除操作. 例如: ...
- Gym - 101670G Ice cream samples(CTU Open Contest 2017 尺取法)
题目: To encourage visitors active movement among the attractions, a circular path with ice cream stan ...
- Gym - 101670H Dark Ride with Monsters(CTU Open Contest 2017 贪心)
题目: A narrow gauge train drives the visitors through the sequence of chambers in the Dark Ride attra ...
- Gym - 101670C Chessboard Dancing(CTU Open Contest 2017 找规律)
题目:链接 思路: 多画出几个情况就可以找出规律来了 Knight (当大于2的时候只要两种颜色相间出现就可以了) King(当大于等于3的时候,总可以用四种形式来补色,具体如下) Bishop(斜 ...
- Gym - 101670B Pond Cascade(CTU Open Contest 2017 贪心,二分)
题目: The cascade of water slides has been installed in the park recently and it has to be tested. The ...
- Gym - 101670J Punching Power(CTU Open Contest 2017 最大独立集)
题目: The park management finally decided to install some popular boxing machines at various strategic ...
- CTU Open Contest 2017
这场题很水.水题我就懒得贴了. B - Pond Cascade 优先队列维护这个水池需要多少时间 或者 直接扫一遍. #include <cstdio> #include <cst ...
随机推荐
- ios32---线程的状态
// // ViewController.m // 04-了解-线程的状态 // // 创建线程是处于新建状态,start是就绪状态,会放入到可调度线程池里面(cpu看线程是否可以调用,是看线程是否在 ...
- POJ 3734 Blocks 矩阵递推
POJ3734 比较简单的递推题目,只需要记录当前两种颜色均为偶数, 只有一种颜色为偶数 两种颜色都为奇数 三个数量即可,递推方程相信大家可以导出. 最后来个快速幂加速即可. #include< ...
- bzoj 3498: PA2009 Cakes【瞎搞】
参考:https://www.cnblogs.com/spfa/p/7495438.html 为什么邻接表会TTTTTTTLE啊...只能用vector? 把点按照点权从大到小排序,把无向边变成排名靠 ...
- 10.12NOIP模拟题(1)
#include<iostream> #include<cstdio> #include<cstring> #include<queue> #defin ...
- [Swift]通天遁地Swift
★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★★➤微信公众号:山青咏芝(shanqingyongzhi)➤博客园地址:山青咏芝(https://www.cnblogs. ...
- knockout 和mvc4结合使用
Knockout (或者Knockout.js ,KnockoutJS)是一个开源的JavaScript库,网址为www.knockoutjs.com.Knockout语法简洁.可读性好,能轻松实现与 ...
- 388 Longest Absolute File Path 最长的绝对文件路径
详见:https://leetcode.com/problems/longest-absolute-file-path/description/ C++: class Solution { publi ...
- [转]Windows Azure平台简介(一):定位与产品结构
本文转自:http://blog.csdn.net/azurechina/article/details/5592236 http://blogs.msdn.com/b/azchina/archive ...
- web开发----jsp中通用模版的引用 include的用法
1.静态引入的示例 通过对两种用法的了解之后 我们现在 使用静态引入 因为上述原因 我的模版页中 只有div 不会有 path等定义 也不会有html标签 如下: 我的header.jsp 全 ...
- 2017-12-04HTML布局_div布局
HTML布局_div布局 <!doctpye> <html> <head> <meta charset = 'utf-8'> <title> ...