读入导致TLE?
  • 板块UVA270 Lining Up
  • 楼主mot1ve
  • 当前回复0
  • 已保存回复0
  • 发布时间2020/9/18 15:50
  • 上次更新2023/11/5 13:03:00
查看原帖
读入导致TLE?
250699
mot1ve楼主2020/9/18 15:50

按理说不该TLE啊

#include<bits/stdc++.h>
using namespace std;
int ans,n,cnt,T,idx,temp1,temp2;
struct node{
	int x,y;
}a[1000010];
int main()
{
	cin>>T;
	while(T--)
	{
	idx=0;
	while(scanf("%d%d",&temp1,&temp2)!=EOF)
	{
		a[++idx].x=temp1;
		a[idx].y=temp2;
	}
	for(int i=1;i<idx;i++)
	{
		for(int j=i+1;j<=idx;j++)//两点确定一条直线 
		{
			cnt=0;
			node vec1,vec2;//平面向量 
			vec1.x=a[j].x-a[i].x;
			vec1.y=a[j].y-a[i].y;
			for(int k=j+1;k<=idx;k++)
			{
				vec2.x=a[k].x-a[i].x;
				vec2.y=a[k].y-a[i].y;
				if(vec1.x*vec2.y==vec1.y*vec2.x)
				cnt++;
			}
			ans=max(ans,cnt);
		}
	}
	printf("%d\n",ans);
    }
	return 0;
}
2020/9/18 15:50
加载中...