H题数据有没有卡常?
为什么H时间复杂度为4e8会超时?
#include<bits/stdc++.h> // #define int long long #define ld double // #define endl '\n' using namespace std; inline int read() { int x = 0, f = 1; char c = getchar(); while (c < '0' || c > '9') { if (c == '-') f = -1; c = getchar(); } while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar(); return x * f; } void solve() { ld a=read(),b=read(),c=read(),d=read(); // cin>>a>>b>>c>>d; ld x1=a,y1=c; ld x2=b,y2=d; int i; ld maxn1=-1e9,x3=-1e9,y3=-1e9; for(i=a+1;i<b;i++)//枚举x { // cout<<i<<" "; ld midx=(i+a)/2,midy=(c+d)/2; assert(a!=i); ld k=(d-c)/(i-a); ld k1=1/k; ld xo=(i+b)/2; ld yo=xo*k1+midy-midx*k1; ld R2=(xo-a)*(xo-a)+(yo-c)*(yo-c); // cout<<R2<<" "; if(R2>maxn1) { maxn1=R2; y3=d; x3=i; // cout<<"jhffbjhvbgfgbfv"; } } // cout<<x3<<" "<<y3<<endl; ld maxn2=-1e9,x4=-1e9,y4=-1e9; for(i=c+1;i<d;i++) { ld midx=(a+b)/2,midy=(i+d)/2; ld k=(d-i)/(b-a); ld k1=1/k; ld yo=(i+c)/2; ld xo=(yo-midy+midx*k1)/k1; ld R2=(xo-a)*(xo-a)+(yo-c)*(yo-c); if(R2>maxn2) { maxn2=R2; x4=a; y4=i; } } // cout<<a<<" "<<c<<endl; printf("%.0lf %.0lf\n",a,c); // cout<<b<<" "<<d<<endl; printf("%.0lf %.0lf\n",b,d); ld R=sqrt((d-c)*(d-c)+(b-a)*(b-a)); R=R/2; R=R*R; if(R>=maxn1&&R>=maxn2) { printf("%.0lf %.0lf\n",a,d); return; } if(maxn1>maxn2) { // cout<<"jmhbvjbhvfjhbr"; printf("%.0lf %.0lf\n",x3,y3); } else printf("%.0lf %.0lf\n",x4,y4); } signed main() { // std::ios::sync_with_stdio(false); // cin.tie(nullptr); // cout.tie(nullptr); int t=read(); // cin>>t; while(t--) { solve(); // cout<<endl; } return 0; }