codeforces 761B Dasha and friends
https://vjudge.net/problem/CodeForces-761B
题意:
有一个圆形跑道,上面有若干个障碍,分别给出两个人距离障碍的距离,问这两个人是否是在同一个跑道上跑步(我是这么理解的,障碍的相对位置相同,那么他们就在同一个跑道上)。
思路:
根据距离计算出障碍之间的距离,然后算两个跑道的距离序列是否一样,当然会有偏移的量,这个时候枚举偏移量就可以了。orz,赛上的时候就是定了一个相同位置就是偏移量在,真是sb。
代码:
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; int main()
{
int a[],b[]; int n,l; scanf("%d%d",&n,&l); for (int i = ;i < n;i++)
scanf("%d",&a[i]); for (int i = ;i < n;i++)
scanf("%d",&b[i]); int c[],d[]; if (n == )
{
printf("YES\n"); return ;
} for (int i = ;i < n - ;i++)
c[i] = a[i + ] - a[i]; c[n-] = l - (a[n-] - a[]); for (int i = ;i < n - ;i++)
d[i] = b[i+] - b[i]; d[n-] = l - (b[n-] - b[]); int f = ; for (int i = ;i < n;i++)
{
for (int j = ;j < n;j++)
{
if (c[j] != d[(i+j)%n]) break; if (j == n - )
{
f = ;
}
} if (f) break;
} if (f) printf("YES\n");
else printf("NO\n"); return ;
}
codeforces 761B Dasha and friends的更多相关文章
- 【codeforces 761B】Dasha and friends
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- codeforces 761D - Dasha and Very Difficult Problem
time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...
- Codeforces 761C Dasha and Password(枚举+贪心)
题目链接 Dasha and Password 题目保证一定有解. 考虑到最多只有两行的指针需要移动,那么直接预处理出该行移动到字母数字或特殊符号的最小花费. 然后O(N^3)枚举求最小值即可. 时间 ...
- Codeforces 761D Dasha and Very Difficult Problem(贪心)
题目链接 Dasha and Very Difficult Problem 求出ci的取值范围,按ci排名从小到大贪心即可. 需要注意的是,当当前的ci不满足在这个取值范围内的时候,判为无解. #in ...
- Codeforces 761E Dasha and Puzzle(构造)
题目链接 Dasha and Puzzle 对于无解的情况:若存在一个点入度大于4,那么直接判断无解. 从根结点出发(假设根结点的深度为0), 深度为0的节点到深度为1的节点的这些边长度为2^30, ...
- Codeforces Round #394 (Div. 2) E. Dasha and Puzzle 构造
E. Dasha and Puzzle 题目连接: http://codeforces.com/contest/761/problem/E Description Dasha decided to h ...
- Codeforces Round #394 (Div. 2) D. Dasha and Very Difficult Problem 贪心
D. Dasha and Very Difficult Problem 题目连接: http://codeforces.com/contest/761/problem/D Description Da ...
- Codeforces Round #394 (Div. 2) C. Dasha and Password 暴力
C. Dasha and Password 题目连接: http://codeforces.com/contest/761/problem/C Description After overcoming ...
- Codeforces Round #394 (Div. 2) B. Dasha and friends 暴力
B. Dasha and friends 题目连接: http://codeforces.com/contest/761/problem/B Description Running with barr ...
随机推荐
- 转载NodePort,LoadBalancer还是Ingress?我该如何选择 - kubernetes
原文:http://mp.weixin.qq.com/s/dHaiX3H421jBhnzgCCsktg ClusterIP ClusterIP服务是Kuberntets的默认服务.它在集群内部生成一个 ...
- webpack打包不识别es6语法的坑
今天Vue项目npm run build 后webpack,报错uglifyjs,自己研究了一下,翻译过来,意思是不识别项目中写的高级语法,这里要把项目里es6语法转es5让浏览器识别, 也就是web ...
- java函数回调
Class A实现接口CallBack callback--背景1 class A中包含一个class B的引用b --背景2 class B有一个参数为callback的方法f(CallBack c ...
- thinkphp3.2-更改控制器名后找不到相应的表?报1146的错
用tp在做着自己的小系统的时候,明明在刚才还是能好好地查到表的,在Service用了'D'方法连自己数据库的表,只是更改了自己的控制器名,却报错了... 我就纳闷了,虽然我的控制器和Service用的 ...
- Linux 开放端口
安装iptables 一般情况下,ubuntu安装好的时候,iptables会被安装上,没有安装上也没啥,一条命令就可以安装了. apt-get install iptables 安装好了之后就可以添 ...
- mysql新手入门随笔
1.启动/关闭服务器 第一种方法:通过Notifier 第二种方法: 通过Windows自带的服务管理:计算机右键选择管理弹出框选择"服务和应用程序"里的服务列表,从列表中找到My ...
- Vue探索历程(一)
使用vue.js原文介绍:Vue.js是一个构建数据驱动的web界面库.Vue.js的目标是通过尽可能简单的API实现响应式数据绑定和组合的视图组件.vue.js上手非常简单,先看看几个例子: 例一: ...
- C#中的String类
一.String类的方法 1. Trim():清除字符串两端的空格 2. ToLower():将字符串转换为小写 3. Equals():比较两个字符串的值,bool 4. IndexOf(value ...
- [高级软件工程教学]团队Beta阶段成绩汇总
一.作业地址: https://edu.cnblogs.com/campus/fzu/AdvancedSoftwareEngineering/homework/1501 二.Beta冲刺课堂答辩 1. ...
- 201621123031 《Java程序设计》第5周学习总结
作业05-继承.多态.抽象类与接口 1. 本周学习总结 1.1 写出你认为本周学习中比较重要的知识点关键词 关键字:接口.继承.多态 1.2 尝试使用思维导图将这些关键词组织起来.注:思维导图一般不需 ...