【链接】点击打开链接


【题意】


n个点,x从左到右严格递增的顺序给出
让你划两条平行的,且没有相同点的直线;
使得它们俩各自最少穿过一个点.
且它们俩穿过了所有的点。

【题解】


枚举第一个点和哪个点组成了一条线,把在线上的点去掉,然后看看剩下的点是不是组成了一条和它平行的线。且穿过了所有的点。
再枚举第一个点单独组成一条线的情况.
O(n^2)复杂度

【错的次数】


0

【反思】


在这了写反思

【代码】

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <vector>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <cstdlib>
#include <cmath>
#include <bitset>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb emplace_back
#define fi first
#define se second
#define ld long double
#define ms(x,y) memset(x,y,sizeof x)
#define ri(x) scanf("%d",&x)
#define rl(x) scanf("%lld",&x)
#define rs(x) scanf("%s",x)
#define rf(x) scnaf("%lf",&x)
#define oi(x) printf("%d",x)
#define ol(x) printf("%lld",x)
#define oc putchar(' ')
#define os(x) printf(x)
#define all(x) x.begin(),x.end()
#define Open() freopen("F:\\rush.txt","r",stdin)
#define Close() ios::sync_with_stdio(0)
#define sz(x) ((int) x.size())
#define ld long double typedef pair<int,int> pii;
typedef pair<LL,LL> pll; //mt19937 myrand(time(0));
//int get_rand(int n){return myrand()%n + 1;}
const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int N = 1e3; struct abc{
LL x,y;
}; int n;
abc a[N+10];
bool bo[N+10]; bool ok(int i,int j,int k){
LL x1 = a[i].x,y1 = a[i].y,x2 = a[j].x,y2 = a[j].y,x3 = a[k].x,y3 = a[k].y;
return (x3-x1)*(y2-y1)==(x2-x1)*(y3-y1);
} bool ok2(int i,int j,int k,int l){
LL x1 = a[i].x,y1 = a[i].y,x2 = a[j].x,y2 = a[j].y;
LL x3 = a[k].x,y3 = a[k].y,x4 = a[l].x,y4 = a[l].y;
return (y2-y1)*(x4-x3) == (y4-y3)*(x2-x1);
} int main(){
//Open();
//Close();
ri(n);
rep1(i,1,n){
LL y;
rl(y);
a[i].x = i,a[i].y = y;
}
rep1(i,2,n){
ms(bo,0);
bo[1] = bo[i] = true;
rep1(j,1,n){
if (ok(1,i,j))
bo[j] = true;
} int fi = -1;
rep1(k,1,n)
if (!bo[k]){
bo[k] = true;
fi = k;
rep1(j,k+1,n)
if (!bo[j]){
if (!ok2(1,i,k,j)) break;
bo[j] = true;
rep1(l,j+1,n)
if (!bo[l] && ok(k,j,l))
bo[l] = true;
break;
}
break;
}
if (fi==-1) continue;
int ok = true;
rep1(j,1,n)
if (!bo[j]){
ok = false;
break;
}
if (ok) return puts("Yes"),0;
}
//��һ���㵥��
ms(bo,0);
bo[1] = true;
int fi = -1;
rep1(i,2,n)
if (!bo[i]){
bo[i] = true;
fi = i;
rep1(j,i+1,n)
if (!bo[j]){
if (ok(1,i,j)) break;
bo[j] = true;
rep1(k,j+1,n)
if (!bo[k] && ok(i,j,k)){
bo[k] = true;
}
break;
}
break;
}
if (fi==-1)
puts("No");
else{
rep1(i,1,n)
if (!bo[i]){
return puts("No"),0;
}
puts("Yes");
} return 0;
}

【Codeforces Round #431 (Div. 2) B】 Tell Your World的更多相关文章

  1. 【Codeforces Round #431 (Div. 2) A】Odds and Ends

    [链接]点击打开链接 [题意] 让你把一个数组分成奇数个部分. 且每个部分的长度都是奇数. [题解] 很简单的脑洞题. 开头和结尾一定要为奇数,然后 n为奇数的话,就选整个数组咯. n为偶数的话,不能 ...

  2. 【Codeforces Round #431 (Div. 2) C】From Y to Y

    [链接]点击打开链接 [题意] 让你构造一个大小最多为10W的字符multiset. 你进行n-1次操作; 每次操作,从set中取出两个字符串,一开始单个字符被认为是字符串. 然后把它们连接在一起. ...

  3. 【Codeforces Round #431 (Div. 1) B】

    [链接]h在这里写链接 [题意] 场上有 n 个点,它们分别向上与向右在不同时刻开始运动,相遇则改变移动方向,求最终这些点到达的坐标. [题解] 先把每个点的坐标都往它本该移动的方向相反的方向退ti个 ...

  4. 【Codeforces Round #432 (Div. 1) B】Arpa and a list of numbers

    [链接]h在这里写链接 [题意] 定义bad list是一个非空的.最大公约数为1的序列.给定一个序列,有两种操作:花费x将一个元素删除.花费y将一个元素加1,问你将这个序列变为good list所需 ...

  5. 【Codeforces Round 431 (Div. 2) A B C D E五个题】

    先给出比赛地址啦,感觉这场比赛思维考察非常灵活而美妙. A. Odds and Ends ·述大意:      输入n(n<=100)表示长度为n的序列,接下来输入这个序列.询问是否可以将序列划 ...

  6. 【Codeforces Round #431 (Div. 1) D.Shake It!】

    ·最小割和组合数放在了一起,产生了这道题目. 英文题,述大意:     一张初始化为仅有一个起点0,一个终点1和一条边的图.输入n,m表示n次操作(1<=n,m<=50),每次操作是任选一 ...

  7. 【Codeforces Round #420 (Div. 2) C】Okabe and Boxes

    [题目链接]:http://codeforces.com/contest/821/problem/C [题意] 给你2*n个操作; 包括把1..n中的某一个数压入栈顶,以及把栈顶元素弹出; 保证压入和 ...

  8. 【Codeforces Round #420 (Div. 2) B】Okabe and Banana Trees

    [题目链接]:http://codeforces.com/contest/821/problem/B [题意] 当(x,y)这个坐标中,x和y都为整数的时候; 这个坐标上会有x+y根香蕉; 然后给你一 ...

  9. 【Codeforces Round #420 (Div. 2) A】Okabe and Future Gadget Laboratory

    [题目链接]:http://codeforces.com/contest/821/problem/A [题意] 给你一个n*n的数组; 然后问你,是不是每个位置(x,y); 都能找到一个同一行的元素q ...

随机推荐

  1. 今日SGU 5.17

    SGU 119 题意:给你一个0-15组成的4*4的矩形,问你能不能回到正常 收获:把矩形变成一维数组,然后判断当前矩形状态到目标状态(逆序对为15)逆序对和0到目标的奇偶性是否不相同,证明题,引荐大 ...

  2. C# textBox控件只允许为数字和小数点并且提取出这个数字

    一. textBox控件实现只允许为数字和小数点 如下图所示,在textBox控件框内输入只能是 要在textBox控件属性设置按键按下的事件触发,如下图所示: 二.源代码 textBox控件只允许为 ...

  3. Mysql学习总结(5)——MySql常用函数大全讲解

    MySQL数据库中提供了很丰富的函数.MySQL函数包括数学函数.字符串函数.日期和时间函数.条件判断函数.系统信息函数.加密函数.格式化函数等.通过这些函数,可以简化用户的操作.例如,字符串连接函数 ...

  4. Java技术——Java泛型详解(转)

    ); for (int i = 0; i < list.size(); i++) { String name = (String) list.get(i); //取出Integer时,运行时出现 ...

  5. 一种基于RGB空间的对照度增强的filter

    今天看前辈博客的时候看到一种新的基于RGB颜色空间的image contrast enhance filter 流浪的鱼link: http://blog.csdn.net/jia20003/arti ...

  6. 谈谈 .NET Reflector

    著名的 .NET Reflector 如今要收费了,价格还不低: .NET Reflector Standard: $95 .NET Reflector VS: $195 .NET Reflector ...

  7. .Net强类型视图

    1.控制器 Controllers/StoreController.cs using System; using System.Collections.Generic; using System.Li ...

  8. Android官方文档翻译——Fragment生命周期

    网上有的博客写得太乱 不如自己翻译官方文档 Lifecycle 生命周期 Though a Fragment's lifecycle is tied to its owning activity, i ...

  9. 76.QT槽的机制

    按钮点击获取文本框输入 void Dialog::on_pushButton_clicked() { //获取文本输入 QString vstr = ui->lineEdit->text( ...

  10. 基于 Web 的 Go 语言 IDE - Wide 1.1.0 发布!

    发布 1.1.0 这个版本改进了很多细节,已经完全可以用于正式项目的开发 同时我们上线了 Wide 在线服务 到目前,我们提供了 Wide 和 Solo 两个在线服务,详情请看这里. Wide 是什么 ...