Submission #60978727


Source Code Expand

Copy
#include<bits/stdc++.h>
#define int long long
#define f(i,j,n) for(int i=j;i<=n;i++)
#define F(i,n,j) for(int i=n;i>=j;i--)
#define updmax(a,b) a=max(a,b)
#define updmin(a,b) a=min(a,b)
#define pb push_back
#define XQZ
using namespace std;
namespace fsd{
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,MAXSIZE,stdin),p1==p2)?EOF:*p1++)
const int MAXSIZE=1<<20;
char buf[MAXSIZE],*p1,*p2;
inline int read(){
int ak=0,ioi=1;char c=gc();
while(!isdigit(c)){if(c=='-')ioi=-1;c=gc();}
while(isdigit(c))ak=ak*10+(c^48),c=gc();
return ak*ioi;
}
inline string reads(){
string o="";
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
#include<bits/stdc++.h>
#define int long long
#define f(i,j,n) for(int i=j;i<=n;i++)
#define F(i,n,j) for(int i=n;i>=j;i--)
#define updmax(a,b) a=max(a,b)
#define updmin(a,b) a=min(a,b)
#define pb push_back
#define XQZ
using namespace std;
namespace fsd{
#define gc() (p1==p2&&(p2=(p1=buf)+fread(buf,1,MAXSIZE,stdin),p1==p2)?EOF:*p1++)
	const int MAXSIZE=1<<20;
	char buf[MAXSIZE],*p1,*p2;
	inline int read(){
		int ak=0,ioi=1;char c=gc();
		while(!isdigit(c)){if(c=='-')ioi=-1;c=gc();}
		while(isdigit(c))ak=ak*10+(c^48),c=gc();
		return ak*ioi;
	}
	inline string reads(){
		string o="";
		char p=gc();
		while(p>'z'||p<'a'){p=gc();}
		while(p<='z'&&p>='a'){o+=p;p=gc();}
		return o;
	}
	inline char readc(){
		char p=gc();
		while(!((p<='z'&&p>='a')||(p<='Z'&&p>='A'))){p=gc();}
		return p;
	}
	inline long double readd(){
		long double ak=0;int ioi=1;char c=gc();
		while(!isdigit(c)){if(c=='-')ioi=-1;c=gc();}
		while(isdigit(c))ak*=10,ak+=c-'0',c=gc();
		c=gc();
		long double q=0.1;
		while(isdigit(c))ak+=(c-'0')*q,q*=0.1,c=gc();
		return ak*ioi;
	}
}
using namespace fsd;
int n;
int x[200010];
int y[200010];
long double rr(int xx,long double yy,int s,int t){
	return (t-yy)*1.0/(s-xx);
}
bool check(long double k){
	long double xy;
	f(i,1,n){
		long double nw=rr(0,k,x[i],y[i]);
		if(i!=1&&xy-nw>-(1e-17)){
			return 0;
		}else xy=nw;
	}
	return 1;
}
void gs(){
	cin>>n;
	f(i,1,n)cin>>x[i]>>y[i];if(check(0)){cout<<-1<<endl;return;}
	long double l=0,r=1000000001;
	while((r-l)>1e-10){
		long double mid=(l+r)/2;
		if(check(mid)){
			r=mid;
		}else l=mid;
	}
	cout<<fixed<<setprecision(10)<<r<<endl;
}
signed main(){
#ifndef XQZ
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
#endif
#ifdef NXD
	int t=0;cin>>t;while(t--)
#endif
		gs();
	return 0;
}

Submission Info

Submission Time
Task F - Visible Buildings
User xiangqizhen
Language C++ 17 (gcc 12.2)
Score 0
Code Size 1845 Byte
Status WA
Exec Time 98 ms
Memory 6860 KB

Compile Error

Main.cpp: In function ‘void gs()’:
Main.cpp:3:18: warning: this ‘for’ clause does not guard... [-Wmisleading-indentation]
    3 | #define f(i,j,n) for(int i=j;i<=n;i++)
      |                  ^~~
Main.cpp:61:9: note: in expansion of macro ‘f’
   61 |         f(i,1,n)cin>>x[i]>>y[i];if(check(0)){cout<<-1<<endl;return;}
      |         ^
Main.cpp:61:33: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the ‘for’
   61 |         f(i,1,n)cin>>x[i]>>y[i];if(check(0)){cout<<-1<<endl;return;}
      |                                 ^~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 0 / 525
Status
AC × 4
AC × 8
WA × 19
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
All hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, sample_01.txt, sample_02.txt, sample_03.txt, sample_04.txt
Case Name Status Exec Time Memory
hand_01.txt WA 1 ms 3744 KB
hand_02.txt WA 1 ms 3672 KB
hand_03.txt WA 1 ms 3720 KB
hand_04.txt AC 1 ms 3532 KB
random_01.txt WA 98 ms 6860 KB
random_02.txt WA 73 ms 5972 KB
random_03.txt WA 63 ms 5700 KB
random_04.txt WA 34 ms 4768 KB
random_05.txt WA 71 ms 6088 KB
random_06.txt WA 37 ms 4884 KB
random_07.txt WA 13 ms 4164 KB
random_08.txt WA 49 ms 5336 KB
random_09.txt WA 8 ms 3892 KB
random_10.txt AC 23 ms 4428 KB
random_11.txt WA 62 ms 5780 KB
random_12.txt WA 45 ms 5196 KB
random_13.txt WA 12 ms 4044 KB
random_14.txt WA 25 ms 4436 KB
random_15.txt WA 89 ms 6148 KB
random_16.txt AC 62 ms 5732 KB
random_17.txt WA 54 ms 5416 KB
random_18.txt WA 71 ms 6060 KB
random_19.txt AC 62 ms 5640 KB
sample_01.txt AC 1 ms 3740 KB
sample_02.txt AC 1 ms 3424 KB
sample_03.txt AC 1 ms 3764 KB
sample_04.txt AC 1 ms 3672 KB


2025-03-05 (Wed)
18:08:30 +00:00