题目链接:http://codeforces.com/problemset/problem/358/A

题目意思:在横坐标上给出n个不同的点,需要把前一个点跟后一个点(这两个点的顺序是紧挨着的)用一个半圆弧来连接。现在要判断的是这些符合条件的点连接以后,圆弧之间是否相交了。是则输出yes,否则输出no。

假设序列是x1,x2,x3,x4.....xn。相交其实只有两种情况,第一种就是样例已经给出了的:即  x1 < x3 < x2 且 x2 < x4。另外一种情况就是第一种情况的对称位置x3 < x1 且 x1 < x4 < x2。

   要特别注意的是,由于序列中前后两个数不是按从小到大的顺序排好的,因此要先确保前一个数要大于后一个数。另外,当n <= 3时,是绝对不会发生交叉的。

 #include <iostream>
#include <cstdio>
#include <cstdlib>
using namespace std; const int maxn = + ;
int a[maxn], tmp1[], tmp2[]; int main()
{
int i, j, n, flag;
while (scanf("%d", &n) != EOF)
{
// freopen("in.txt", "r", stdin);
for (i = ; i < n; i++)
{
scanf("%d", &a[i]);
}
if (n <= )
{
printf("no\n");
}
else
{
flag = ;
for (i = ; i < n-; i++)
{
if (a[i] > a[i+])
{
tmp1[] = a[i+];
tmp1[] = a[i];
}
else
{
tmp1[] = a[i];
tmp1[] = a[i+];
}
// printf("tmp1[0] = %d, tmp1[1] = %d\n", tmp1[0], tmp1[1]);
for (j = ; j < n-; j++)
{
if (a[j] > a[j+])
{
tmp2[] = a[j+];
tmp2[] = a[j];
}
else
{
tmp2[] = a[j];
tmp2[] = a[j+];
}
if ((tmp1[] > tmp2[] && tmp1[] < tmp2[] && tmp1[] > tmp2[]) || (tmp1[] < tmp2[] && tmp1[] > tmp2[] && tmp1[] < tmp2[]))
{
flag = ;
// printf("tmp1[0] = %d, tmp1[1] = %d\n", tmp1[0], tmp1[1]);
// printf("tmp2[0] = %d, tmp2[1] = %d\n", tmp2[0], tmp2[1]);
goto h;
}
}
}
h: if (!flag)
printf("no\n");
else
printf("yes\n");
}
}
return ;
}

codeforces A. Dima and Continuous Line 解题报告的更多相关文章

  1. codeforces B. Dima and Text Messages 解题报告

    题目链接:http://codeforces.com/problemset/problem/358/B 题目意思:给出n个单词(假设为word1,word2.word3...wordn)和一句test ...

  2. codeforces A. Cinema Line 解题报告

    题目链接:http://codeforces.com/problemset/problem/349/A 题目意思:题目不难理解,从一开始什么钱都没有的情况下,要向每一个人售票,每张票价格是25卢布,这 ...

  3. codeforces B. Shower Line 解题报告

    题目链接:http://codeforces.com/contest/431/problem/B 题目意思:给出5 * 5 的矩阵.从这个矩阵中选出合理的安排次序,使得happiness之和最大.当第 ...

  4. Codeforces Round #208 (Div. 2) A.Dima and Continuous Line

    #include <iostream> #include <algorithm> #include <vector> using namespace std; in ...

  5. codeforces C1. The Great Julya Calendar 解题报告

    题目链接:http://codeforces.com/problemset/problem/331/C1 这是第一次参加codeforces比赛(ABBYY Cup 3.0 - Finals (onl ...

  6. codeforces B. Eugeny and Play List 解题报告

    题目链接:http://codeforces.com/problemset/problem/302/B 题目意思:给出两个整数n和m,接下来n行给出n首歌分别的奏唱时间和听的次数,紧跟着给出m个时刻, ...

  7. codeforces 433C. Ryouko's Memory Note 解题报告

    题目链接:http://codeforces.com/problemset/problem/433/C 题目意思:一本书有 n 页,每页的编号依次从 1 到 n 编排.如果从页 x 翻到页 y,那么| ...

  8. 【LeetCode】149. Max Points on a Line 解题报告(Python)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 题目大意 解题方法 字典+最大公约数 日期 题目地址:https://l ...

  9. 【LeetCode】581. Shortest Unsorted Continuous Subarray 解题报告(Python & C++)

    作者: 负雪明烛 id: fuxuemingzhu 个人博客: http://fuxuemingzhu.cn/ 目录 题目描述 解题方法 方法一:排序比较 日期 题目地址:https://leetco ...

随机推荐

  1. BZOJ1202 狡猾的商人

    HNOI2005 Day1 T4 Description 刁姹接到一个任务,为税务部门调查一位商人的账本,看看账本是不是伪造的.账本上记录了n个月以来的收入情况,其中第i 个月的收入额为Ai(i=1, ...

  2. sqlserver字段类型详解

    抄了一篇不错的数据库类型,来自:http://www.cnblogs.com/andy_tigger/archive/2011/08/21/2147745.html bit 整型 bit数据类型是整型 ...

  3. BZOJ2301 莫比乌斯反演

    题意:a<=x<=b,c<=y<=d,求满足gcd(x,y)=k的数对(x,y)的数量         ((x,y)和(y,x)不算同一个) 比hdu1695多加了个下界,还有 ...

  4. Opencv不用每次创建项目配置vs2010 vc++目录 库目录等项

    可以设置成编译器的环境配置,VS2010相对其他版本虽然去掉了编译器配置 但可以通过属性管理器配置编译器环境. 设置对应的vc++目录 链接器就可以了,这样就是对整个编译器配置了 下次就不用再配了.

  5. linux虚拟机系统的复制或克隆后续问题解决!

    前言 加快创建hadoop或spark集群,方法有两种途径:克隆或复制.其实啊,我最近,再返回写下本博文,理清下思路. 比如,你在你的一台电脑里,安装虚拟机.已经搭建好了hadoop或spark集群. ...

  6. easyUI框架之学习2--添加左侧导航栏

    <head> function addTab(title, url) { if ($('#tableContainer').tabs('exists', title)) { $('#tab ...

  7. 解决IE apk变成zip:Android 手机应用程序文件下载服务器 配置解决方法

    APK文件其实是zip格式,但后缀名被修改为apk,通过UnZip解压后,可以看到Dex文件,Dex是Dalvik VM executes的全称,即Android Dalvik执行程序,并非Java ...

  8. 锋利的jQuery-2--一个显示和隐藏的例子,主要看写法

    例子:如图,默认不显示全部,点击按钮来回切换,全部显示是一部分推荐的品牌高亮. $(function(){ //dom加载完再执行 var category = $('ul li:gt(5):not( ...

  9. BurpSuite之SQL Injection

    BurpSuite之SQL Injection[平台]:mutillidae[工具]BurpSuite 1.4.07 + FireFox1:安装配置mutillidae如果遇到问题,开下面的帖子.ht ...

  10. SQL注入攻击技巧总结

    0×01 你要知道目前有哪些数据库 微软公司旗下的: Microsoft SQL server 简称 MS-SQL 或者 SQL SERVER (大型数据库操作,功能和性能异常强大)(一般也是ASP或 ...