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事务管理总结
本文是对慕课网上"搞定SSM开发"路径的系列课程的总结,详细的项目文档和课程总结放在github上了.点击查看 本文对应慕课网上课程Spring事务管理,详情可查看:点我 1: 概 ...
- git push的用法
git push <远程仓库名> <本地分支名>:<远程分支名>
- Java NIO (四) 选择器(Selector)
选择器(Selector) 是 SelectableChannle 对象的多路复用器,Selector 可以同时监控多个 SelectableChannel 的 IO 状况,也就是说,利用 Selec ...
- 聊聊API网关的作用
p.p1 { margin: 0.0px 0.0px 0.0px 0.0px; font: 10.5px "Trebuchet MS" } p.p2 { margin: 0.0px ...
- KD树
k-d树 在计算机科学里,k-d树( k-维树的缩写)是在k维欧几里德空间组织点的数据结构.k-d树可以使用在多种应用场合,如多维键值搜索(例:范围搜寻及最邻近搜索).k-d树是空间二分树(Binar ...
- copy&deepcopy
import copy 字典参照列表结论,看是否有深层嵌套. a = {'name':1,'age':2} b = a a['name'] = 'ff' print(a) print(b) print ...
- 通过 python的 __call__ 函数与元类 实现单例模式
简单一句话,当一个类实现__call__方法时,这个类的实例就会变成可调用对象. 直接上测试代码 class ClassA: def __call__(self, *args, **kwargs): ...
- GUI—ST_emWin移植
GUI-ST_emWin移植 一.st_emwin移植 1.stemwin源文件下载:ST官网 https://my.st.com/content/my_st_com/en/search.html#q ...
- MapReduce Tutorial(划重点)
Mapper Mapper的maps阶段将输入键值对经过计算得到中间结果键值对,框架会将中间结果按照key进行分组,然后传递给reducer以决定最终的输出.用户可以通过Job.setGrouping ...
- 欢迎来到Hadoop
What Is Apache Hadoop? Hadoop是一个可靠的.可扩展的.分布式计算的开源软件. Hadoop是一个分布式处理大数据的框架.它被设计成从一台到上千台不等的服务器,每个服务器都提 ...