博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
AtCoder Regular Contest 089
阅读量:7227 次
发布时间:2019-06-29

本文共 3503 字,大约阅读时间需要 11 分钟。

这场一边吃饭一边打,确实还是很菜的

C - Traveling


Time limit : 2sec / Memory limit : 256MB

Score : 300 points

Problem Statement

AtCoDeer the deer is going on a trip in a two-dimensional plane. In his plan, he will depart from point (0,0) at time 0, then for each ibetween 1 and N (inclusive), he will visit point (xi,yi) at time ti.

If AtCoDeer is at point (x,y) at time t, he can be at one of the following points at time t+1(x+1,y)(x−1,y)(x,y+1) and (x,y−1). Note that he cannot stay at his place. Determine whether he can carry out his plan.

Constraints

  • 1  N  105
  • 0  xi  105
  • 0  yi  105
  • 1  ti  105
  • ti < ti+1 (1  i  N−1)
  • All input values are integers.

Input

Input is given from Standard Input in the following format:

Nt1 x1 y1t2 x2 y2:tN xN yN

Output

If AtCoDeer can carry out his plan, print Yes; if he cannot, print No.


Sample Input 1

Copy
23 1 26 1 1

Sample Output 1

Copy
Yes

For example, he can travel as follows: (0,0)(0,1)(1,1)(1,2)(1,1)(1,0), then (1,1).


Sample Input 2

Copy
12 100 100

Sample Output 2

Copy
No

It is impossible to be at (100,100) two seconds after being at (0,0).


Sample Input 3

Copy
25 1 1100 1 1

Sample Output 3

Copy
No

 这个题目不难,就是给你坐标问你能不能到达,首先可以想想能不能到的问题,只要两点需要的步数<=你要走的步数,不直接到的话都是多走偶数步,所以只需要判断奇偶和大小就可以了

#include
using namespace std;int main(){ int n,t=0,x=0,y=0,f=0; cin>>n; for(int i=0,tt,tx,ty;i
>tt>>tx>>ty; if((abs(tx-x)+abs(ty-y))%2!=(tt-t)%2||abs(tx-x)+abs(ty-y)>(tt-t)) f=1; t=tt,x=tx,y=ty; } if(!f)cout<<"Yes"; else cout<<"No"; return 0;}

D - Checker


Time limit : 2sec / Memory limit : 256MB

Score : 500 points

Problem Statement

AtCoDeer is thinking of painting an infinite two-dimensional grid in a checked pattern of side K. Here, a checked pattern of side K is a pattern where each square is painted black or white so that each connected component of each color is a K × K square. Below is an example of a checked pattern of side 3:

cba927b2484fad94fb5ff7473e9aadef.png

AtCoDeer has N desires. The i-th desire is represented by xiyi and ci. If ci is B, it means that he wants to paint the square (xi,yi) black; if ci is W, he wants to paint the square (xi,yi) white. At most how many desires can he satisfy at the same time?

Constraints

  • 1  N  105
  • 1  K  1000
  • 0  xi  109
  • 0  yi  109
  • If i  j, then (xi,yi)  (xj,yj).
  • ci is B or W.
  • NKxi and yi are integers.

Input

Input is given from Standard Input in the following format:

N Kx1 y1 c1x2 y2 c2:xN yN cN

Output

Print the maximum number of desires that can be satisfied at the same time.


Sample Input 1

Copy
4 30 1 W1 2 W5 3 B5 4 B

Sample Output 1

Copy
4

He can satisfy all his desires by painting as shown in the example above.


Sample Input 2

Copy
2 10000 0 B0 1 W

Sample Output 2

Copy
2

Sample Input 3

Copy
6 21 2 B2 1 W2 2 B1 0 B0 6 W4 5 W

Sample Output 3

Copy
4

D题也不难吧,但是自己比较笨,并没有做出来

先讲一下题意吧,就是你有一盘黑白棋,每个正方形黑白块的宽度都是k,但是这个黑白棋的起始位置还没有确定,你现在有一个序列,你需要知道其中最多几个有效

n是很大的啊,但是要注意到k很小,所以起始位置就没那么多了,我们需要做的是去枚举起始位置。

但是怎么去解决那个庞大的n呢,因为如果n不大的话我们就可以直接4*k*k*n的做法了,所以这个题目需要二维前缀和去查询,坐标先%一下,之后加加减减就可以了

#include
using namespace std;int n,k,f[2005][2005],s[2005][2005],t;int S(int i,int j){ return i>=0&&j>=0?s[min(t-1,i)][min(t-1,j)]:0;}int get(int i,int j){ return S(i,j)-S(i,j-k)-S(i-k,j)+S(i-k,j-k);}int main(){ cin>>n>>k; t=k*2; string st; for(int i=0,x,y; i
>x>>y>>st; if(st=="B")x+=k; f[x%t][y%t]++; } for(int i=0; i

 

转载于:https://www.cnblogs.com/BobHuang/p/8335305.html

你可能感兴趣的文章
基于 HTML5 WebGL 的 3D 机房
查看>>
Java编程——数据库两大神器:索引和锁
查看>>
springMvc学习笔记(2)
查看>>
吐槽Javascript系列二:数组中的splice和slice方法
查看>>
什么是Javascript函数节流?
查看>>
MQ框架的比较
查看>>
oschina
查看>>
Octave 入门
查看>>
深度学习入门:10门免费线上课程推荐
查看>>
React组件设计模式(一)
查看>>
E-HPC支持多队列管理和自动伸缩
查看>>
express + mock 让前后台并行开发
查看>>
30天自制操作系统-2
查看>>
小程序开发之路(一)
查看>>
Odoo domain写法及运用
查看>>
JavaScript工作原理(五):深入了解WebSockets,HTTP/2和SSE,以及如何选择
查看>>
猫头鹰的深夜翻译:Java 2D Graphics, 简单的仿射变换
查看>>
面试题:给你个id,去拿到name,多叉树遍历
查看>>
go append函数以及写入
查看>>
关于Java中分层中遇到的一些问题
查看>>