AtCoder Regular Contest 089
这场一边吃饭一边打,确实还是很菜的
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
2
3 1 2
6 1 1
Sample Output 1
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
1
2 100 100
Sample Output 2
No
It is impossible to be at (100,100) two seconds after being at (0,0).
Sample Input 3
2
5 1 1
100 1 1
Sample Output 3
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 xi, yi 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
orW
. - N, K, xi 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
4 3
0 1 W
1 2 W
5 3 B
5 4 B
Sample Output 1
4
He can satisfy all his desires by painting as shown in the example above.
Sample Input 2
2 1000
0 0 B
0 1 W
Sample Output 2
2
Sample Input 3
6 2
1 2 B
2 1 W
2 2 B
1 0 B
0 6 W
4 5 W
Sample Output 3
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的更多相关文章
- Atcoder Regular Contest 089 D - ColoringBalls(DP)
Atcoder 题面传送门 & 洛谷题面传送门 神仙题. 在下文中,方便起见,用 R/B 表示颜色序列中球的颜色,用 r/b 表示染色序列中将连续的区间染成的颜色. 首先碰到这一类计算有多少个 ...
- AtCoder Regular Contest 061
AtCoder Regular Contest 061 C.Many Formulas 题意 给长度不超过\(10\)且由\(0\)到\(9\)数字组成的串S. 可以在两数字间放\(+\)号. 求所有 ...
- AtCoder Regular Contest 094 (ARC094) CDE题解
原文链接http://www.cnblogs.com/zhouzhendong/p/8735114.html $AtCoder\ Regular\ Contest\ 094(ARC094)\ CDE$ ...
- AtCoder Regular Contest 092
AtCoder Regular Contest 092 C - 2D Plane 2N Points 题意: 二维平面上给了\(2N\)个点,其中\(N\)个是\(A\)类点,\(N\)个是\(B\) ...
- AtCoder Regular Contest 093
AtCoder Regular Contest 093 C - Traveling Plan 题意: 给定n个点,求出删去i号点时,按顺序从起点到一号点走到n号点最后回到起点所走的路程是多少. \(n ...
- AtCoder Regular Contest 094
AtCoder Regular Contest 094 C - Same Integers 题意: 给定\(a,b,c\)三个数,可以进行两个操作:1.把一个数+2:2.把任意两个数+1.求最少需要几 ...
- AtCoder Regular Contest 095
AtCoder Regular Contest 095 C - Many Medians 题意: 给出n个数,求出去掉第i个数之后所有数的中位数,保证n是偶数. \(n\le 200000\) 分析: ...
- AtCoder Regular Contest 102
AtCoder Regular Contest 102 C - Triangular Relationship 题意: 给出n,k求有多少个不大于n的三元组,使其中两两数字的和都是k的倍数,数字可以重 ...
- AtCoder Regular Contest 096
AtCoder Regular Contest 096 C - Many Medians 题意: 有A,B两种匹萨和三种购买方案,买一个A,买一个B,买半个A和半个B,花费分别为a,b,c. 求买X个 ...
随机推荐
- 转 winfrom如何通过http来进行通信,并且通过传递json格式的数据可接受json格式的数据
string username = this.textBox1.Text; string password = this.textBox2.Text; string AA = HttpUtility. ...
- Modelsim与Simulink协同仿真
当使用硬件描述语言(HDL)完成电路设计时,往往需要编写Testbench对所设计的电路进行仿真验证,测试设计电路的功能是否与预期的目标相符.而编写Testbench难度之大,这时可以借助交互式图形化 ...
- JS给数字加千位分隔符
本文原链接:https://www.jianshu.com/p/928c68f92c0c JavaScript实现千位分隔符 将普通的数字转换为带千位分隔符格式的数字字符串是一个非常常见的问题,千位分 ...
- 《剑指offer》39题—数组中出现次数超过一半的数字
题目描述 数组中有一个数字出现的次数超过数组长度的一半,请找出这个数字.例如输入一个长度为9的数组{1,2,3,2,2,2,5,4,2}.由于数字2在数组中出现了5次,超过数组长度的一半,因此输出2. ...
- 虚拟机设置NAT
需要开启虚拟机网络相关服务, 安装虚拟网卡, 还有必须安装 VMware Tools VMware虚拟机下实现NAT方式上网1. 把你的虚拟网卡VMnet8设置为自动获得IP.自动获得DNS服务器,启 ...
- 01_13_Struts_默认Action
01_13_Struts_默认Action 1. 配置struts默认Action <package name="default" namespace="/&quo ...
- Element-ui tree组件自定义节点使用方法
工作上使用到element-ui tree 组件,主要功能是要实现节点拖拽和置顶,通过自定义内容方法(render-content)渲染树代码如下~ <template> <di ...
- JavaScript的基础知识
1,标识符 标识符是程序中常量或变量命名的一种术语称呼,并不是所有的字符组成都是一个合法的标识符,规范如下: 标识符的组成部分可以是字母,数字,下划线或美元($)符号 标识符开头是字母,下划线或美元( ...
- [BZOJ] 1520: [POI2006]Szk-Schools
费用流解决. abs内传不了int..CE一次 #include<iostream> #include<cstring> #include<cstdio> #inc ...
- linux三剑客正则表达式
^:以...开头,^d,意思是以d开头.例如:ls -F(-p) | grep " ^d " $:以...结尾,/$,意思是以/结尾.例如:ls -F(-p) | grep &q ...