http://codeforces.com/contest/761/problem/B

题意:

有一个长度为l的环形跑道,跑道上有n个障碍,现在有2个人,给出他们每过多少米碰到障碍,判断他们跑的是不是同一个跑道。

思路:

如果是同一个跑道,那么障碍与障碍之间的距离是相同的。

所以我们可以先计算出两个人的跑道的障碍之间的距离,然后暴力比较,如果全部一样就是同一个跑道(因为是环形跑道,所以在比较的时候每次都需要将第一个加到最后)。

 #include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cstdio>
using namespace std; int n,l;
int a[],b[];
int A[],B[*]; int main()
{
//freopen("D:\\input.txt", "r", stdin);
while(~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 sum=;
for(int i=;i<n;i++)
{
A[i-]=a[i]-a[i-];
sum+=a[i]-a[i-];
}
A[n-]=l-sum; sum=;
for(int i=;i<n;i++)
{
B[i-]=b[i]-b[i-];
sum+=b[i]-b[i-];
}
B[n-]=l-sum; bool flag=false;
for(int t=;t<n;t++)
{
for(int i=;i<n;i++)
{
if(A[i]!=B[(i+t)%n]) break;
if(i==n-) flag=true;
}
if(flag) break;
}
if(flag) puts("YES");
else puts("NO");
}
return ;
}

Codeforces Round #394 (Div. 2) B. Dasha and friends(暴力)的更多相关文章

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

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

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

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

  3. Codeforces Round #394 (Div. 2) B. Dasha and friends —— 暴力 or 最小表示法

    题目链接:http://codeforces.com/contest/761/problem/B B. Dasha and friends time limit per test 2 seconds ...

  4. Codeforces Round #394 (Div. 2) E. Dasha and Puzzle(分形)

    E. Dasha and Puzzle time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

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

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

  7. Codeforces Round #394 (Div. 2) A. Dasha and Stairs 水题

    A. Dasha and Stairs 题目连接: http://codeforces.com/contest/761/problem/A Description On her way to prog ...

  8. Codeforces Round #394 (Div. 2) D. Dasha and Very Difficult Problem —— 贪心

    题目链接:http://codeforces.com/contest/761/problem/D D. Dasha and Very Difficult Problem time limit per ...

  9. Codeforces Round #394 (Div. 2) C. Dasha and Password —— 枚举

    题目链接:http://codeforces.com/problemset/problem/761/C C. Dasha and Password time limit per test 2 seco ...

  10. Codeforces Round #394 (Div. 2) C. Dasha and Password

    C. Dasha and Password time limit per test 2 seconds memory limit per test 256 megabytes input standa ...

随机推荐

  1. Linux进程数据结构详解

    1.Linux的进程简介: 支持多线程的操作系统中,进程是资源分配的最小单位,线程是调度的基本单位.Linux是现代的32位或64位的支持多线程的操作系统,不过Linux是一种以轻量级进程作为线程,多 ...

  2. SSH配置优化和慢的解决方法

    author: headsen chen date: 2018-08-18  00:28:37 ssh配置优化 vim  /etc/ssh/sshd_config 1,修改root端口 2,不允许ro ...

  3. intellijIDEA常用快捷键以及和Eclipse快捷键的对照

    ​CTRL + D 复制当前行到下一行  相当于eclipse中的 CTRL + SHIFT + 下 CTRL + /  单行注释和反注释 CTRL +SHIFT + / 块儿注释和反注释 CTRL ...

  4. Lucene4.x创建索引与3.x的一些不同

    lucene3.x的时候创建Field的时候可以直接指定存储和索引的选项类下下边这样: doc.add(new Field("createrId",diaryField.getCr ...

  5. Windows 2008 server R2安装.NET Framework4时提示“灾难性故障”

    报错信息: 安装.NET Framework 4时,提示安装未成功,“灾难性故障”.服务器的操作系统是windows  server 2008 R2. 查看系统日志时显示“无法安装 Windows 更 ...

  6. Windows Phone 上拉刷新、下拉刷新

    ScrollViewer scrollViewer = new ScrollViewer(); // 构造函数 public MainPage() { InitializeComponent(); ; ...

  7. R中的各种概率统计分布

    名称 名称 R对应的名字 附加参数 β分布 beta beta shape1, shape2, ncp 二项式分布 binomial binom size, prob 柯西分布 Cauchy cauc ...

  8. 关于typecho,404页面错误

    之前用typecho,但是没发现404错误页面; 现在只要发布文章就提示404页面错误. 解决方法 点击发布日期,将发布日期的分向后拖动几分钟: 然后发布,发现404错误不见了: 我是遇到这种情况了不 ...

  9. python基础之练习题(二)

    九九乘法表 i = 0 #while 九九乘法表 j = 0 while i < 9: i += 1 while j<9: j += 1 sum = i + j total="% ...

  10. JSON数组成员反序列化

    场景: 构想客户端能够传递如下格式JSON字符串到服务端: {"KeyValueSetList":[{"SN":"RQ1001"," ...