S集合中有n个点,是否存在三个点构成三角形的外接圆,且S集合的所有点都不在外接圆内
这样的三角形有很多种情况,所以任找一点 a ,找到其距离最近的点 b , 然后遍历其他的点 i ,找到 ∠aib最小的点,它们构成的三角形外接圆一定是满足条件的。
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <time.h>
#include <bitset>
#define INF 0x3f3f3f3f
#define eps 1e-6
#define PI 3.1415926
#define mod 1000000007
#define base 2333
using namespace std;
typedef long long LL;
const int inf = 1e9;
const int maxn = 1e6 + 10;
const int maxx = 7e5 + 10;
inline void splay(int &v) {
v=0;char c=0;int p=1;
while(c<'0' || c >'9'){if(c=='-')p=-1;c=getchar();}
while(c>='0' && c<='9'){v=(v<<3)+(v<<1)+c-'0';c=getchar();}
v*=p;
}
int n, x[maxn], y[maxn];
int dis(int i, int j) {
return (x[i]-x[j])*(x[i]-x[j])+(y[i]-y[j])*(y[i]-y[j]);
}
int line(int i, int j, int k) {
if((y[k]-y[i])*(x[j]-x[i]) == (y[j]-y[i])*(x[k]-x[i]))
return 1;
return 0;
}
void solve() {
splay(n);
for(int i = 1; i <= n; i++)
splay(x[i]), splay(y[i]);
int a = 1, b = 0, c = 0, aa, bb, cc = 1e9;
for(int i = 2; i <= n; i++) {
if(dis(a, i) <= cc) {
cc = dis(a, i);
b = i;
}
}
double co, xx = 1e9;
for(int i = 2; i <= n; i++) {
if(i == b) continue;
if(line(a, b, i)) continue;
aa = dis(b, i), bb = dis(a, i);
co = (aa+bb-cc)/(2.0*sqrt(aa)*sqrt(bb));
if(xx > co)
xx = co, c = i;
}
if(c) printf("Yes\n%d %d %d\n", a, b, c);
else printf("No\n");
}
int main() {
//srand(time(NULL));
//freopen("kingdom.in","r",stdin);
//freopen("kingdom.out","w",stdout);
solve();
}