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

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:

N
t1 x1 y1
t2 x2 y2
:
tN xN yN

Output

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


Sample Input 1

Copy
2
3 1 2
6 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
1
2 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
2
5 1 1
100 1 1

Sample Output 3

Copy
No

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

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

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:

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 K
x1 y1 c1
x2 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 3
0 1 W
1 2 W
5 3 B
5 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 1000
0 0 B
0 1 W

Sample Output 2

Copy
2

Sample Input 3

Copy
6 2
1 2 B
2 1 W
2 2 B
1 0 B
0 6 W
4 5 W

Sample Output 3

Copy
4

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

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

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

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

#include<bits/stdc++.h>
using namespace std;
int n,k,f[][],s[][],t;
int S(int i,int j)
{
return i>=&&j>=?s[min(t-,i)][min(t-,j)]:;
}
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*;
string st;
for(int i=,x,y; i<n; i++)
{
cin>>x>>y>>st;
if(st=="B")x+=k;
f[x%t][y%t]++;
}
for(int i=; i<t; i++)
for(int j=; j<t; j++)
s[i][j]=S(i,j-)+f[i][j];
for(int i=; i<t; i++)
for(int j=; j<t; j++)
s[i][j]+=S(i-,j);
int ans=;
for(int i=; i<t; i++)
for(int j=; j<t; j++)
ans=max(ans,get(i,j)+get(i-k,j-k)+get(i-k,j+k)+get(i+k,j-k)+get(i+k,j+k)+get(i+t,j)+get(i,j+t));
printf("%d\n",ans);
return ;
}

AtCoder Regular Contest 089的更多相关文章

  1. Atcoder Regular Contest 089 D - ColoringBalls(DP)

    Atcoder 题面传送门 & 洛谷题面传送门 神仙题. 在下文中,方便起见,用 R/B 表示颜色序列中球的颜色,用 r/b 表示染色序列中将连续的区间染成的颜色. 首先碰到这一类计算有多少个 ...

  2. AtCoder Regular Contest 061

    AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...

  3. AtCoder Regular Contest 094 (ARC094) CDE题解

    原文链接http://www.cnblogs.com/zhouzhendong/p/8735114.html $AtCoder\ Regular\ Contest\ 094(ARC094)\ CDE$ ...

  4. AtCoder Regular Contest 092

    AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...

  5. AtCoder Regular Contest 093

    AtCoder Regular Contest 093 C - Traveling Plan 题意: 给定n个点,求出删去i号点时,按顺序从起点到一号点走到n号点最后回到起点所走的路程是多少. \(n ...

  6. AtCoder Regular Contest 094

    AtCoder Regular Contest 094 C - Same Integers 题意: 给定\(a,b,c\)三个数,可以进行两个操作:1.把一个数+2:2.把任意两个数+1.求最少需要几 ...

  7. AtCoder Regular Contest 095

    AtCoder Regular Contest 095 C - Many Medians 题意: 给出n个数,求出去掉第i个数之后所有数的中位数,保证n是偶数. \(n\le 200000\) 分析: ...

  8. AtCoder Regular Contest 102

    AtCoder Regular Contest 102 C - Triangular Relationship 题意: 给出n,k求有多少个不大于n的三元组,使其中两两数字的和都是k的倍数,数字可以重 ...

  9. AtCoder Regular Contest 096

    AtCoder Regular Contest 096 C - Many Medians 题意: 有A,B两种匹萨和三种购买方案,买一个A,买一个B,买半个A和半个B,花费分别为a,b,c. 求买X个 ...

随机推荐

  1. BaseAdapter.notifyDataSetChanged()之观察者设计模式及源码分析

    BaseAdapter.notifyDataSetChanged()的实现涉及到设计模式-观察者模式,详情请参考我之前的博文设计模式之观察者模式 Ok,回到notifyDataSetChanged进行 ...

  2. Java 原型模式(克隆模式)

      Java 的设计模式有 23 种,前段时间小编已经介绍了单例模式,由于我们在学习 Spring 的时候在 bean 标签的学习中碰到了今天要讲的原型模式,那么小编就已本文来介绍下原型模式. 原型模 ...

  3. JS编程规范指南

    原文:github.com/ryanmcdermott/clean-code-javascript 说明:本文翻译自 github 上的一个项目,只取部分精华. 一.变量 用有意义且常用的单词命名 / ...

  4. Dojo中的选择器

    dom.byId(以前的dojo.byId):等同于js中的document.getElementById. http://www.cnblogs.com/tiandi/archive/2013/11 ...

  5. 使用jquery-validate校验表单

    注意: 表单校验(validation校验[需要下载JQuery-validate插件,而且必须要在引入JQuery插件之后,再引入validate插件/*validate是建立在JQuery之上*/ ...

  6. Bootstrap历练实例:导航内的下拉菜单

    <!DOCTYPE html><html><head><meta http-equiv="Content-Type" content=&q ...

  7. Spring中使用事务搭建转账环境 转账操作,

    演示不使用事务出现异常情况 Dao层两个方法lessMoney()和moreMoney() package com.swift; import org.springframework.jdbc.cor ...

  8. cocos2dx for lua 简单的翻牌动画

    local x = 20 local y = display.height/2 for i = 1,16 do--创建16张 local cardFg = display.newSprite(&quo ...

  9. jq封装插件,简单dome

    (function($) { $.fn.extend({ bold: function() { this.css({ fontWeight: "bold", color: 'red ...

  10. Boo who-freecodecamp算法题目

    Boo who 1.要求 检查一个值是否是基本布尔类型,并返回 true 或 false. 基本布尔类型即 true 和 false 2.思路 利用switch语句判断输入的数据是true/false ...