题解:P13667 [GCPC 2023] Balloon Darts
blackwhitekey · · 题解
题解:P13667 [GCPC 2023] Balloon Darts
思路
首先,我们看看数据范围,
代码
#include <bits/stdc++.h>
using namespace std;
const int N=1e4+100;
int n;
int ax[N];
int ay[N];
int b[N];
int main()
{
cin>>n;
for(int i=1; i<=n; i++)
cin>>ax[i]>>ay[i];
int t=1000;
while(t--)
{
for(int i=1; i<=n; i++)
b[i]=0;
int ans=0,x,y;
for(int i=1; i<=3; i++)
{
while(1)
{
if(ans==n)
break;
x=rand()%n+1;
if(b[x]==0)
break;
}
b[x]=1;
ans=min(ans+1,n);
while(1)
{
if(ans==n)
break;
y=rand()%n+1;
if(b[y]==0)
break;
}
b[y]=1;
ans=min(ans+1,n);
for(int j=1; j<=n; j++)
{
if(b[j]==0)
{
if(abs((ay[j]-ay[x])*(ax[y]-ax[x])-(ay[y]-ay[x])*(ax[j]-ax[x]))==0)
{
b[j]=1;
ans++;
}
}
}
}
if(ans==n)
{
cout<<"possible";
return 0;
}
}
cout<<"impossible";
return 0;
}