CodeForces 1500A Going Home|思维
题意:
给出(a),需要找到四个坐标使 (a_x+a_y=a_z+a_w)
(4le nle 2 imes 10^5) (1le a_ile 2.5 imes 10^6)
题目思路:tmd太离谱了
对于(a_x+a_y),必小于(5 imes 10^6)
故枚举 (5 imes 10^6 +1) 次,必有答案。不会超时,枚举即可。跑的飞快
#include<bits/stdc++.h>
using namespace std;
int n,a[200100];
struct po
{
int x,y;
}p[9000000];
int main()
{
cin>>n;
for (int i=1;i<=n;i++)
cin>>a[i];
for (int i=1;i<=n;i++)
{
for (int j=i+1;j<=n;j++)
{
if (i!=j)
{
int cnt=a[i]+a[j];
if ((p[cnt].x||p[cnt].y)&&(p[cnt].y!=i&&p[cnt].y!=j&&p[cnt].x!=i&&p[cnt].x!=j))
{
cout<<"YES
"<<p[cnt].x<<" "<<p[cnt].y<<" "<<i<<" "<<j<<endl;
return 0;
}
else p[cnt].x=i,p[cnt].y=j;
}
}
}
cout<<"NO
";
return 0;
}
没有题出可以不出(无能狂怒)