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个 ...
随机推荐
- 【extjs6学习笔记】1.4 初始:ajax请求django应用
使用sencha创建应用,默认如下: personnel数据使用的是本地数据 做以下修改,使用ajax 启动时会报404[此次调用是使用nginx部署] django应用app_jiake中,修改vi ...
- 在openSUSE 13.1上用gem安装rails无反应: gem install rails
解决方案: gem install rails -V ....其实他本身在后台运行,白白的给他中断好多次,用-V这个选项就可以直接回显信息了
- UVA 11572 Unique snowflakes (滑窗)
用set,保存当前区间出现过的数字,如果下一个数字没有出现过,加入,否则删掉左端点,直到没有重复为止 #include<bits/stdc++.h> using namespace std ...
- jQuery向界面输出时保留两位小数
通过JSTL下的<fmt:formatNumber>标签实现,具体实现代码如下: <%@ taglib uri="http://java.sun.com/jsp/jstl/ ...
- data命令详解
Linux date命令的用法 在linux shell编程中,经常用到日期的加减运算 以前都是自己通过expr函数计算,很麻烦 其实date命令本身提供了日期的加减运算 非常方便.例如:得到昨天的时 ...
- MFC 菜单编程 -- 总结
菜单结构 一个菜单栏可以有若干个子菜单,而一个子菜单又可有若干个菜单项.对于菜单栏的子菜单,由左至右从0开始索引.对于特定的子菜单的菜单项,由上至下建立从0开始的索引.访问子菜单和菜单项,均可通过其索 ...
- python源码剖析学习记录-01
学习<Python源码剖析-深度探索动态语言核心技术>教程 Python总体架构,运行流程 File Group: 1.Core Modules 内部模块,例如:imp ...
- C#基础-数组-冒泡排序
冒泡排序基础 冒泡排序原理图分析 tmp在算法中起到数据交换的作用 int[] intNums = { 12,6,9,3,8,7 }; int tmp = intNums[0]; // 一共5次冒泡, ...
- DeepFaceLab小白入门(6):脸部替换以及合成视频!
前面的都是准备工作,这个环节才是真的换脸.换脸主要分两部分,1,图片换脸,2,把图片合成视频. 7) convert H64 debug.bat 这个环节是和训练环节相对于的,比如我们之前选的是H64 ...
- MyBatis的增删改查操作
搭建好mybatis之后 进行对数据库的操作 添加语句 在映射文件中添加语句 insert into student(name,age,score) values(#{name},#{age},#{s ...