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. 原生js写的flybird小游戏

    游戏地址:http://zangzhihong.jusukeji.com/flybird/index.html html部分 <!DOCTYPE html>   <!-- This ...

  2. delete与delete[]的区别

    一直对C++中的delete和delete[]的区别不甚了解,今天遇到了,上网查了一下,得出了结论.做个备份,以免丢失. C++告诉我们在回收用 new 分配的单个对象的内存空间的时候用 delete ...

  3. ng-if ng-show ng-hide区别(面试题)

    ng-if ng-show  ng-hide区别 实现原理方面: ng-show/ng-hide是通过修改css样式方式控制元素显示与隐藏,对应的DOM元素会一直存在于当前页面中: 而ng-if根据表 ...

  4. Factorials

    Factorials 阶乘 题目大意:给你一个数n,求出n ! 的最后一个非零位. 注释:n<=4200 想法:开始的想法是觉得这道题应该比较的有趣,因为我们知道,一个数的阶乘的最后的非零位后面 ...

  5. echarts对每个data[i]的图片添加点击事件

    1.综述:以饼图为例,只需要对echarts对象option添加以下几行代码即可 //添加点击事件(单击),还有其他鼠标事件和键盘事件等等 myChart1.on("click", ...

  6. 移动端Web资源整合

    meta基础知识 H5页面窗口自动调整到设备宽度,并禁止用户缩放页面 <meta name="viewport" content="width=device-wid ...

  7. Win7(64Bit旗舰版) 安装 PL/SQL Developer图解说明

    Win7逐渐成为现行主流的windows操作系统,其32和64位系统平分秋色.然而当下还没有64位的PL/SQL Developer问世,直接用32位的PL/SQL Developer连接Win7(6 ...

  8. [W班]第二次结对作业成绩评价

    作业地址: https://edu.cnblogs.com/campus/fzu/FZUSoftwareEngineering1715W/homework/1016 作业要求: 1.代码具有规范性. ...

  9. 201621123060《JAVA程序设计》第十三周学习总结

    1. 本周学习总结 以你喜欢的方式(思维导图.OneNote或其他)归纳总结多网络相关内容. 2. 为你的系统增加网络功能(购物车.图书馆管理.斗地主等)-分组完成 为了让你的系统可以被多个用户通过网 ...

  10. 局域网下访问其他计算机搭建的django网页

    1.修改工程目录下的setting.py 文件 ALLOWED_HOSTS = ['*'] #*表示允许访问的ip 如果是添加* 则允许所有同局域网环境的主机访问 2.在完成的django工程下运行以 ...