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 ...
随机推荐
- Linux使用ssh公钥实现免批量分发管理服务器
ssh 无密码登录要使用公钥与私钥.linux下可以用用ssh-keygen生成公钥/私钥对,下面我以CentOS为例. 管理机器外网IP10.0.0.61(内网172.16.1.61) 服务器外网1 ...
- 巧用linux版powershell,管理linux下的docker
大家好,我把用powershell的docker马甲命令的好处,放在了页面下方,从第五章开始. powershell 传教士 原创文章 始于 2017-09-07 允许转载,但必须保留名字和出处,否则 ...
- mysqldump 备份脚本
#!/bin/bash DUMP=/usr/bin/mysqldump OUT_DIR=/home/mysql LINUX_USER=root DB_NAME=snale DB_USER=root D ...
- Android权限Uri.parse的几种用法(转载)
1,调web浏览器 Uri myBlogUri = Uri.parse("http://xxxxx.com"); returnIt = new Intent(Intent.ACTI ...
- Android类参考---SQLiteOpenHelper
public 抽象类 SQLiteOpenHelper 继承关系 java.lang.Object |____android.database.sqlite.SQLiteOpenHelper 类概要 ...
- javaAPI中的常用 类 以及接口
java.lang包中的常用类以及接口 类 1. Integer :Integer 类在对象中包装了一个基本类型 int 的值.Integer 类型的对象包含一个 int 类型的字段. 2. Math ...
- Hibernate学习笔记二
Hibernate持久化类的编写规则 Hibernate是持久层的ORM映射框架,专注于数据的持久化工作.所谓持久化,就是将内存中的数据永久存储到关系型数据库中. 持久化类 一个java类与数据库表建 ...
- Beta阶段敏捷冲刺报告-DAY1
Beta阶段敏捷冲刺报告-DAY1 Scrum Meeting 敏捷开发日期 2017.11.2 讨论时间 20:30 讨论地点 下课路上以及院楼侧门 参会人员 项目组全体成员 会议内容 附加功能讨论 ...
- 第四十六条:for-each循环优先于传统的for循环
for(Elements e : list) { //doSomeThing-- }
- 关于java中的数组
前言:最近刚刚看完了<Java编程思想>中关于数组的一章,所有关于Java数组的知识,应该算是了解的差不多了.在此再梳理一遍,以便以后遇到模糊的知识,方便查阅. Java中持有对象的方式, ...