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的更多相关文章

  1. 【codeforces 761B】Dasha and friends

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  2. codeforces 761D - Dasha and Very Difficult Problem

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  3. Codeforces 761C Dasha and Password(枚举+贪心)

    题目链接 Dasha and Password 题目保证一定有解. 考虑到最多只有两行的指针需要移动,那么直接预处理出该行移动到字母数字或特殊符号的最小花费. 然后O(N^3)枚举求最小值即可. 时间 ...

  4. Codeforces 761D Dasha and Very Difficult Problem(贪心)

    题目链接 Dasha and Very Difficult Problem 求出ci的取值范围,按ci排名从小到大贪心即可. 需要注意的是,当当前的ci不满足在这个取值范围内的时候,判为无解. #in ...

  5. Codeforces 761E Dasha and Puzzle(构造)

    题目链接 Dasha and Puzzle 对于无解的情况:若存在一个点入度大于4,那么直接判断无解. 从根结点出发(假设根结点的深度为0), 深度为0的节点到深度为1的节点的这些边长度为2^30, ...

  6. 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 ...

  7. 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 ...

  8. Codeforces Round #394 (Div. 2) C. Dasha and Password 暴力

    C. Dasha and Password 题目连接: http://codeforces.com/contest/761/problem/C Description After overcoming ...

  9. Codeforces Round #394 (Div. 2) B. Dasha and friends 暴力

    B. Dasha and friends 题目连接: http://codeforces.com/contest/761/problem/B Description Running with barr ...

随机推荐

  1. 关于VS2017+Qt5.6.3(msvc2015_64)联合编程Qt project settings界面没有ok,cancel选项的问题

    如题,我在项目开发的过程中,需要添加数据库模块SQL,然后发现VS上QT project settings选项中不能修改添加的模块,也就是对应QT creator中的在.pro文件中添加一句:QT + ...

  2. 【windows】 配置一个本地的tomcat服务器

    配置tomcat 公司的许多业务都是用java+tomcat模式的,做本地测试的时候经常要搭建一个自己的tomcat服务器.整个操作不难,但是记录一下,万一以后遇到什么问题也可以放这里. ■ 安装ja ...

  3. 【Linux】 文本比较工具 diff和cmp

    Linux 文本比较工具 ■ diff命令 diff用于逐行比较两个文本文件,列出其不同之处 diff [option] <file1> <file2> file1和file2 ...

  4. JS实现键盘监听

    不说废话直接上正文: <html> <head> <meta http-equiv="Content-Type" content="text ...

  5. 使用Java编译思想

    1.Java常见的注释有哪些,语法是怎样的? 1)单行注释用//表示,编译器看到//会忽略该行//后的所文本 2)多行注释/* */表示,编译器看到/*时会搜索接下来的*/,忽略掉/* */之间的文本 ...

  6. Spark Job的提交与task本地化分析(源码阅读)

    Spark中任务的处理也要考虑数据的本地性(locality),Spark目前支持PROCESS_LOCAL(本地进程).NODE_LOCAL(本地节点).NODE_PREF.RACK_LOCAL(本 ...

  7. QTableView

    QTableView常用于实现数据的表格显示.下面我们如何按步骤实现学生信息表格: 一 添加表头 //准备数据模型     QStandardItemModel *student_model = ne ...

  8. 搭建java环境——使用Sublime Text 3(windows环境)

    实现sublime Text 3对Java编译执行 参考网址:http://tieba.baidu.com/p/2609515186 1.1直接在安装路径下找到*\Packages\Java.subl ...

  9. 2017北京国庆刷题Day4 morning

    期望得分:0+40+30=70 实际得分:0+10+10=20 题目修改:只能由0变1,只能用一次操作 大模拟 #include<cstdio> #include<cstring&g ...

  10. 从PRISM开始学WPF(三)Prism-Region?

    从PRISM开始学WPF(一)WPF? 从PRISM开始学WPF(二)Prism? 从PRISM开始学WPF(三)Prism-Region? 从PRISM开始学WPF(四)Prism-Module? ...