【链接】点击打开链接
【题意】
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; }