poj 2434;bzoj 1686 [Usaco2005 Open]Waves 波纹
Description
Input
Output
Sample Input
-3 0 1
0 0 2
Sample Output
-*------X
*-*-*---X
-o-*-*--X
o-----*-X
-o-*-*--X
*-*-*---X
-*------X
--------X

#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int n,m1,m2,r,x,y,t,xx,yy,ti,ll,rr,qaq,i,j;
bool f;
int map[][];
void sp(){
while(ti--){
if (f){
yy++;
if (yy==m1||yy==m2) yy--,f=;
}else{
yy--;
if (yy==m1||yy==m2) yy++,f=;
}
}
}
void op(){
ll=max(,x-t),rr=min(,x+t);
for (i=ll;i<=rr;i++){
ti=min(i-(x-t),(x+t)-i);xx=i,yy=y;
f=;sp();
if (yy>=&&yy<=) map[xx][yy]+=qaq;
if (i==x-t||i==x+t) continue;
ti=min(i-(x-t),(x+t)-i);xx=i;yy=y;
f=;sp();
if (yy>=&&yy<=) map[xx][yy]+=qaq;
}
}
int main(){
scanf("%d%d%d%d",&n,&m1,&m2,&r);
m1+=;m2+=;
while(n--){
scanf("%d%d%d",&y,&x,&t);
x+=;y+=;
t=r-t;
qaq=;op();
t-=;
if (t>=) qaq=-,op();
}
for (i=;i>=;i--){
for (j=;j<=;j++)
if (j==m1||j==m2) printf("X");else if (map[i][j]==) printf("-");else if (map[i][j]>=) printf("*");else if (map[i][j]<=-) printf("o");
printf("\n");
}
}
然后还有修改后的
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std; int n,m1,m2,r,x,y,t,xx,yy,ti,ll,rr,qaq,i,j;
bool f;
int map[][];
void ssp(){
if (f){
if (ti<m2-yy){
yy+=ti;
return;
}
if (ti<=m2-yy){
yy+=ti-;
return;
}
ti-=m2-yy;
yy=m2-;
f=;ssp();
}else{
if (ti<yy-m1){
yy-=ti;
return;
}
if (ti<=yy-m1){
yy-=ti-;
return;
}
ti-=yy-m1;
yy=m1+;
f=;ssp();
}
}
void sp(){
if (yy<m1&&(!f)) yy-=ti;else
if (yy>m2&&f) yy+=ti;else
if (yy>m2&&(!f)){
if (ti<yy-m2) yy-=ti;else
if (ti<=yy-m2) yy-=ti-;else
ti-=yy-m2,f=,yy=m2+,sp();
return;
}else
if (yy<m1&&f){
if (ti<m1-yy) yy+=ti;else
if (ti<=m1-yy) yy+=ti-;else
ti+=m1-yy,f=,yy=m1-,sp();
return;
}else{
ti%=(m2-m1-)*;
ssp();
}
return;
}
void op(){
ll=max(,x-t),rr=min(,x+t);
for (i=ll;i<=rr;i++){
ti=min(i-(x-t),(x+t)-i);xx=i,yy=y;
f=;sp();
if (yy>=&&yy<=) map[xx][yy]+=qaq;
if (i==x-t||i==x+t) continue;
ti=min(i-(x-t),(x+t)-i);xx=i;yy=y;
f=;sp();
if (yy>=&&yy<=) map[xx][yy]+=qaq;
}
}
int main(){
scanf("%d%d%d%d",&n,&m1,&m2,&r);
if (m1>m2) swap(m1,m2);
m1+=;m2+=;
while(n--){
scanf("%d%d%d",&y,&x,&t);
x+=;y+=;
t=r-t;
qaq=;op();
t-=;
if (t>=) qaq=-,op();
}
for (i=;i>=;i--){
for (j=;j<=;j++)
if (j==m1||j==m2) printf("X");else if (map[i][j]==) printf("-");else if (map[i][j]>=) printf("*");else if (map[i][j]<=-) printf("o");
printf("\n");
}
}
poj 2434;bzoj 1686 [Usaco2005 Open]Waves 波纹的更多相关文章
- 【模拟】bzoj1686: [Usaco2005 Open]Waves 波纹
打完模拟题来庆祝一波:):感觉最近陷入一种“口胡五分钟打题两小时”的巨坑之中…… Description Input 第1行:四个用空格隔开的整数Pj Bi,B2,R. P(1≤P≤5)表示石 ...
- bzoj:1687;poj 2434:[Usaco2005 Open]Navigating the City 城市交通
Description A dip in the milk market has forced the cows to move to the city. The only employment av ...
- HDU 3062 && HDU 1824 && POJ 3678 && BZOJ 1997 2-SAT
一条边<u,v>表示u选那么v一定被选. #include <iostream> #include <cstring> #include <cstdio> ...
- POJ 1061 BZOJ 1477 Luogu P1516 青蛙的约会 (扩展欧几里得算法)
手动博客搬家: 本文发表于20180226 23:35:26, 原地址https://blog.csdn.net/suncongbo/article/details/79382991 题目链接: (p ...
- Bzoj 1687: [Usaco2005 Open]Navigating the City 城市交通 广搜,深搜
1687: [Usaco2005 Open]Navigating the City 城市交通 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 122 So ...
- Bzoj 1674: [Usaco2005]Part Acquisition dijkstra,堆
1674: [Usaco2005]Part Acquisition Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 337 Solved: 162[Sub ...
- [BZOJ 1733] [Usaco2005 feb] Secret Milking Machine 【二分 + 最大流】
题目链接:BZOJ - 1733 题目分析 直接二分这个最大边的边权,然后用最大流判断是否可以有 T 的流量. 代码 #include <iostream> #include <cs ...
- BZOJ 1739: [Usaco2005 mar]Space Elevator 太空电梯
题目 1739: [Usaco2005 mar]Space Elevator 太空电梯 Time Limit: 5 Sec Memory Limit: 64 MB Description The c ...
- BZOJ 1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚
题目 1672: [Usaco2005 Dec]Cleaning Shifts 清理牛棚 Time Limit: 5 Sec Memory Limit: 64 MB Description Farm ...
随机推荐
- spring mvc报错,数据库查询无限死循环
进行查询的陷入了无限死循环,原因是问题类中包含了回答,回答类中包含了问题,进入了无限死循环 解决方法:在回答类中的问题类属性上加注解:@JsonBackReference 问题中有回答的set集合,回 ...
- [array] leetcode - 41. First Missing Positive - Hard
leetcode - 41. First Missing Positive - Hard descrition Given an unsorted integer array, find the fi ...
- ReactNative布局样式总结
flex number 用于设置或检索弹性盒模型对象的子元素如何分配空间 flexDirection enum('row', 'row-reverse' ,'column','column-rever ...
- MySQL in or效率对比
本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/60 考虑如下两个sql: select * from table ...
- 598. Range Addition II
Given an m * n matrixMinitialized with all0's and several update operations. Operations are represen ...
- 如何检测mvc性能和sql语句
mvc中使用linq如何检测sql语句 .net中使用mvc开发已经是一种趋势,不仅仅是.net ,java 等越来越多的开发者更倾向于mvc这种开发模式,在.net mvc 使用linq非常方便,各 ...
- jmeter通过org.sqlite.JDBC驱动连接db数据库
最近遇到个项目,默认业务库为内置db数据库,在性能脚本编辑过程中要通过正则表达式提取器(关联)获取对应的id号,通过该id号到db数据库中查找对应的数据源name字段内容,为下一个post请求做par ...
- python 中一些关键字的区别
一.raw_input 和input input和raw_input都可以读取控制台的输入,但是input和raw_input在处理数字时是有区别的 1.当输入为纯数字时 input返回的是数值类型, ...
- 【http转https】其之二:申请Let's Encrypt颁发SSL证书
文:铁乐猫 2017年1月12日 申请Let's Encrypt颁发SSL证书 由 ISRG(Internet Security Research Group,互联网安全研究小组)提供服务, ISRG ...
- ASP.NET Core学习之三 NLog日志
上一篇简单介绍了日志的使用方法,也仅仅是用来做下学习,更何况只能在console输出. NLog已是日志库的一员大佬,使用也简单方便,本文介绍的环境是居于.NET CORE 2.0 ,目前的版本也只有 ...