QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#720759#8985. Bikes and BarricadesN_z_AC ✓1ms4048kbC++236.4kb2024-11-07 13:58:592024-11-07 13:59:02

Judging History

This is the latest submission verdict.

  • [2024-11-07 13:59:02]
  • Judged
  • Verdict: AC
  • Time: 1ms
  • Memory: 4048kb
  • [2024-11-07 13:58:59]
  • Submitted

answer

#include<bits/stdc++.h>
using namespace std;
struct time_helper{
#ifdef LOCAL
clock_t time_last;time_helper(){time_last=clock();}void test(){auto time_now=clock();std::cerr<<"time:"<<1.*(time_now-time_last)/CLOCKS_PER_SEC<<";all_time:"<<1.*time_now/CLOCKS_PER_SEC<<std::endl;time_last=time_now;}~time_helper(){test();}
#else
void test(){}
#endif
}time_helper;
#ifdef LOCAL
#include"dbg.h"
#else
#define dbg(...) (__VA_ARGS__)
#endif
namespace Fread{const int SIZE=1<<16;char buf[SIZE],*S,*T;inline char getchar(){if(S==T){T=(S=buf)+fread(buf,1,SIZE,stdin);if(S==T)return'\n';}return *S++;}}namespace Fwrite{const int SIZE=1<<16;char buf[SIZE],*S=buf,*T=buf+SIZE;inline void flush(){fwrite(buf,1,S-buf,stdout);S=buf;}inline void putchar(char c){*S++=c;if(S==T)flush();}struct NTR{~NTR(){flush();}}ztr;}
#define getchar Fread::getchar
#define putchar Fwrite::putchar
int print_precision=10;bool print_T_endl=1;char print_between=' ';
template<typename T>struct is_char{static constexpr bool value=(std::is_same<T,char>::value||std::is_same<T,signed char>::value||std::is_same<T,unsigned char>::value);};template<typename T>struct is_integral_ex{static constexpr bool value=(std::is_integral<T>::value||std::is_same<T,__int128>::value)&&!is_char<T>::value;};template<typename T>struct is_floating_point_ex{static constexpr bool value=std::is_floating_point<T>::value||std::is_same<T,__float128>::value;};namespace Fastio{struct Reader;struct Writer;template<size_t id>struct read_tuple{template<typename...T>static void read(Reader&stream,std::tuple<T...>&x){read_tuple<id-1>::read(stream,x);stream>>get<id-1>(x);}};template<>struct read_tuple<0>{template<typename...T>static void read([[maybe_unused]]Reader&stream,[[maybe_unused]]std::tuple<T...>&x){}};template<size_t id>struct print_tuple{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){print_tuple<id-1>::print(stream,x);putchar(print_between);stream<<get<id-1>(x);}};template<>struct print_tuple<1>{template<typename...T>static void print(Writer&stream,const std::tuple<T...>&x){stream<<get<0>(x);}};template<>struct print_tuple<0>{template<typename...T>static void print([[maybe_unused]]Writer&stream,[[maybe_unused]]const std::tuple<T...>&x){}};
struct Reader{template<typename T>typename std::enable_if_t<std::is_class<T>::value,Reader&>operator>>(T&x){for(auto &y:x)*this>>y;return *this;}template<typename...T>Reader&operator>>(std::tuple<T...>&x){read_tuple<sizeof...(T)>::read(*this,x);return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1;while(c<'0'||c>'9'){if(c=='-')f*=-1;c=getchar();}x=0;while(c>='0'&&c<='9'){x=(x<<1)+(x<<3)+(c^48);c=getchar();}x*=f;return *this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Reader&>operator>>(T&x){char c=getchar();short f=1,s=0;x=0;T t=0;while((c<'0'||c>'9')&&c!='.'){if(c=='-')f*=-1;c=getchar();}while(c>='0'&&c<='9'&&c!='.')x=x*10+(c^48),c=getchar();if(c=='.')c=getchar();else return x*=f,*this;while(c>='0'&&c<='9')t=t*10+(c^48),s++,c=getchar();while(s--)t/=10.0;x=(x+t)*f;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Reader&>operator>>(T&c){c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();return *this;}Reader&operator>>(char*str){int len=0;char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str[len++]=c,c=getchar();str[len]='\0';return*this;}template<typename T1,typename T2>Reader&operator>>(std::pair<T1,T2>&x){*this>>x.first>>x.second;return *this;}Reader&operator>>(std::string&str){str.clear();char c=getchar();while(c=='\n'||c==' '||c=='\r')c=getchar();while(c!='\n'&&c!=' '&&c!='\r')str.push_back(c),c=getchar();return*this;}Reader(){}}cin;const char endl='\n';
struct Writer{typedef __int128 mxdouble;template<typename T>typename std::enable_if_t<std::is_class<T>::value,Writer&>operator<<(const T&x){for(auto q:x){*this<<q;if(!is_class<decltype(q)>::value)*this<<print_between;}if(!is_class<typename T::value_type>::value&&print_T_endl)*this<<'\n';return *this;}template<typename...T>Writer&operator<<(const std::tuple<T...>&x){print_tuple<sizeof...(T)>::print(*this,x);if(print_T_endl)*this<<'\n';return *this;}template<typename T>typename std::enable_if_t<is_integral_ex<T>::value,Writer&>operator<<(T x){if(x==0)return putchar('0'),*this;if(x<0)putchar('-'),x=-x;static int sta[45];int top=0;while(x)sta[++top]=x%10,x/=10;while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_floating_point_ex<T>::value,Writer&>operator<<(T x){if(x<0)putchar('-'),x=-x;x+=pow(10,-print_precision)/2;mxdouble _=x;x-=(T)_;static int sta[45];int top=0;while(_)sta[++top]=_%10,_/=10;if(!top)putchar('0');while(top)putchar(sta[top]+'0'),--top;putchar('.');for(int i=0;i<print_precision;i++)x*=10;_=x;while(_)sta[++top]=_%10,_/=10;for(int i=0;i<print_precision-top;i++)putchar('0');while(top)putchar(sta[top]+'0'),--top;return*this;}template<typename T>typename std::enable_if_t<is_char<T>::value,Writer&>operator<<(const T&c){putchar(c);return*this;}Writer&operator<<(char*str){int cur=0;while(str[cur])putchar(str[cur++]);return *this;}Writer&operator<<(const char*str){int cur=0;while(str[cur])putchar(str[cur++]);return*this;}template<typename T1,typename T2>Writer&operator<<(const std::pair<T1,T2>&x){*this<<x.first<<print_between<<x.second;if(print_T_endl)*this<<'\n';return *this;}Writer&operator<<(const std::string&str){int st=0,ed=str.size();while(st<ed)putchar(str[st++]);return*this;}Writer(){}}cout;}
#define cin Fastio::cin
#define cout Fastio::cout
#define endl Fastio::endl
template<class Fun>class y_combinator_result{Fun fun_;public:template<class T>explicit y_combinator_result(T &&fun): fun_(std::forward<T>(fun)) {}template<class ...Args>decltype(auto) operator()(Args &&...args){return fun_(std::ref(*this), std::forward<Args>(args)...);}};template<class Fun>decltype(auto) y_combinator(Fun &&fun){return y_combinator_result<std::decay_t<Fun>>(std::forward<Fun>(fun));}

void init();void solve(int tc);
main()
{
	init();int t=1;
	// cin>>t;
	for(int tc=1;tc<=t;tc++)solve(tc);
}
void init()
{
}
void solve([[maybe_unused]]int tc)
{
	int n;
	cin>>n;
	double ans=1e9;
	while(n--)
	{
		int x1,y1,x2,y2;
		cin>>x1>>y1>>x2>>y2;
		if(x1>x2)swap(x1,x2),swap(y1,y2);
		if(x1>0||x2<0)continue;
		double d0=y1-1.*(y2-y1)/(x2-x1)*x1;
		if(d0>=0)ans=min<double>(ans,d0);
	}
	if(ans==1e9)ans=-1;
	cout<<ans<<endl;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3772kb

input:

2
-10 7 5 19
-1 -1 8 21

output:

1.4444444444

result:

ok found '1.44444', expected '1.44444', error '0.00000'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3980kb

input:

2
4 -6 -12 -1
3 5 8 8

output:

-1.0000000000

result:

ok found '-1.00000', expected '-1.00000', error '-0.00000'

Test #3:

score: 0
Accepted
time: 1ms
memory: 3892kb

input:

1
1 -2 1 3

output:

-1.0000000000

result:

ok found '-1.00000', expected '-1.00000', error '-0.00000'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3960kb

input:

1
10 19 -20 19

output:

19.0000000000

result:

ok found '19.00000', expected '19.00000', error '0.00000'

Test #5:

score: 0
Accepted
time: 1ms
memory: 3996kb

input:

1000
2 -30 46 25
59 15 78 -78
49 -74 9 35
-45 -34 55 -18
-81 -66 -79 -85
63 -9 99 27
64 94 29 -29
-40 -41 -39 -33
-92 0 -83 -80
-100 64 -2 68
97 -93 57 -31
87 99 -44 -91
-20 -50 68 24
73 -78 37 96
-57 -38 28 -82
-83 46 -66 -8
11 -18 21 72
-82 -7 -11 9
26 -62 45 45
31 13 24 33
35 11 98 -42
57 -23 69 ...

output:

-1.0000000000

result:

ok found '-1.00000', expected '-1.00000', error '-0.00000'

Test #6:

score: 0
Accepted
time: 1ms
memory: 3788kb

input:

1000
36 -21 1 -27
16 -90 -22 -36
54 -69 58 -52
62 15 91 -90
-50 -91 -74 -7
75 -68 -18 -50
-50 67 -72 -58
39 -18 -67 -70
48 -67 -88 73
45 89 67 28
-60 -36 75 21
-83 -20 97 -14
-87 -91 -4 11
-45 -48 -21 -8
-32 25 -45 -78
-91 90 -47 -1
-68 -61 6 -84
-27 17 -58 9
46 -76 -16 -24
74 48 91 87
45 -66 -67 21...

output:

-1.0000000000

result:

ok found '-1.00000', expected '-1.00000', error '-0.00000'

Test #7:

score: 0
Accepted
time: 1ms
memory: 4048kb

input:

1000
-67 13 28 -24
-50 -93 -5 44
35 -27 -14 0
39 -8 -100 -19
-25 -86 47 3
-38 29 -43 50
60 -44 96 -61
13 79 73 -28
44 29 8 52
60 -51 3 5
-75 85 4 -87
91 8 32 -38
19 -63 52 -81
-56 -85 57 49
19 49 28 29
-38 -87 50 22
-34 -11 2 -46
96 -9 42 -26
-80 85 -12 96
60 85 54 54
81 -99 35 -39
-80 -27 -15 59
-1...

output:

-1.0000000000

result:

ok found '-1.00000', expected '-1.00000', error '-0.00000'

Test #8:

score: 0
Accepted
time: 0ms
memory: 3720kb

input:

1000
-96 67 9 -80
-97 -50 16 -46
-7 -77 -73 18
-19 -33 84 -18
15 -65 46 32
-32 85 -87 -53
-99 -84 -73 -48
34 -92 12 6
94 51 -10 -32
43 0 -18 -60
68 -69 -42 18
-42 22 67 -89
-24 41 -4 -11
-21 -71 37 -3
-12 97 -9 59
-10 -28 -70 4
-70 9 -36 26
-80 -35 97 -2
-77 -49 -9 -82
13 -41 -34 93
9 -80 53 71
12 -...

output:

-1.0000000000

result:

ok found '-1.00000', expected '-1.00000', error '-0.00000'

Test #9:

score: 0
Accepted
time: 0ms
memory: 3904kb

input:

1000
-92 -84 -38 88
-13 -72 -25 -82
48 49 -30 -69
7 -95 21 -91
79 72 94 65
10 94 4 -37
-69 -81 93 -65
23 54 63 60
34 89 43 78
-100 81 -15 0
47 -71 -91 85
-87 39 41 -30
-57 -57 63 37
-58 13 -98 -10
-8 82 -87 -89
47 -70 92 -10
53 -69 80 -60
12 57 74 39
-99 -61 87 -9
-43 19 -59 -60
99 -11 86 -61
24 -30...

output:

-1.0000000000

result:

ok found '-1.00000', expected '-1.00000', error '-0.00000'

Test #10:

score: 0
Accepted
time: 1ms
memory: 4044kb

input:

1000
-52 47 -45 -81
-38 -73 -58 -100
68 -35 8 36
-86 53 22 76
30 -71 -44 -52
31 -95 64 -5
58 -47 37 38
-40 -29 -57 76
-56 -40 84 93
-37 26 16 -15
-18 34 -45 -44
-38 -19 -58 -25
55 41 -87 -97
80 -55 23 11
-75 -12 31 -47
51 36 -19 -7
40 59 7 -85
83 -59 65 -1
-86 -85 -26 -87
79 83 32 -23
79 68 -85 54
-...

output:

0.3488372093

result:

ok found '0.34884', expected '0.34884', error '0.00000'

Test #11:

score: 0
Accepted
time: 0ms
memory: 3840kb

input:

1000
55 57 -86 -37
83 81 2 10
4 15 26 94
-75 13 58 -76
-61 15 89 65
34 -31 -78 4
74 -50 -3 75
-100 -54 -21 -20
32 29 -42 -63
77 8 -65 -65
-11 -59 -93 43
-12 -49 -54 62
-61 11 17 -96
31 5 84 49
-59 -98 71 -96
3 -30 -42 -49
74 8 -78 91
36 55 -26 36
80 52 25 10
86 13 23 81
-3 77 77 27
-32 60 61 -51
-89...

output:

0.3894736842

result:

ok found '0.38947', expected '0.38947', error '0.00000'

Test #12:

score: 0
Accepted
time: 0ms
memory: 3860kb

input:

1000
-8 -32 85 53
-43 -33 -56 -29
53 21 29 -73
-82 68 -81 -44
86 -25 23 5
18 -97 -69 -35
52 79 -44 99
76 76 5 22
-17 37 25 -48
89 -59 -44 -63
-90 71 -64 46
64 -88 -57 -97
-66 -48 46 21
-61 83 94 -65
-16 -71 78 81
-55 71 38 89
-61 -89 -37 -8
32 -18 69 -65
-98 -26 11 -50
53 -92 -77 47
46 51 -87 0
35 -...

output:

0.1654135338

result:

ok found '0.16541', expected '0.16541', error '0.00000'

Test #13:

score: 0
Accepted
time: 0ms
memory: 3980kb

input:

1000
24 -71 -17 0
-32 15 68 95
74 -49 46 8
84 83 83 31
-52 44 77 -92
-29 -17 -93 -44
79 9 -34 41
25 61 73 28
22 44 47 -94
8 81 -70 10
93 -6 76 41
76 73 -31 -50
31 -51 68 -60
-77 5 6 82
36 -17 83 -36
-24 -2 -58 85
9 -76 -89 70
-2 -85 -26 -88
-65 -9 88 98
-84 24 58 7
-47 -43 -23 54
-85 24 -83 -4
12 -9...

output:

0.5000000000

result:

ok found '0.50000', expected '0.50000', error '0.00000'

Test #14:

score: 0
Accepted
time: 1ms
memory: 3892kb

input:

1000
-18 1 11 77
-80 -53 -22 95
16 -3 -39 78
87 -85 54 -6
-55 13 -85 -38
82 -85 -5 -37
-36 -46 88 10
19 10 75 -60
48 27 -67 -37
-64 -61 78 -40
70 61 91 19
-43 51 86 52
-38 1 76 -41
23 67 -32 -94
39 -65 67 -84
-69 87 -37 6
-45 74 -98 60
27 -17 51 -9
-63 85 -53 -34
74 25 11 -81
96 -36 -58 -11
-27 -95 ...

output:

0.2869565217

result:

ok found '0.28696', expected '0.28696', error '0.00000'

Test #15:

score: 0
Accepted
time: 1ms
memory: 3712kb

input:

10
-28 97 74 97
47 100 76 95
63 99 84 98
-34 98 11 99
-48 93 16 91
54 100 85 91
-80 97 27 95
-90 94 82 96
66 100 -74 91
-18 92 37 100

output:

91.5000000000

result:

ok found '91.50000', expected '91.50000', error '0.00000'

Test #16:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

10
57 94 75 100
15 95 26 96
34 98 -60 97
-37 99 -92 99
2 92 -63 98
22 91 -73 97
-83 91 -90 94
-19 90 -12 100
-26 97 -23 91
99 90 -38 95

output:

92.1846153846

result:

ok found '92.18462', expected '92.18462', error '0.00000'

Test #17:

score: 0
Accepted
time: 1ms
memory: 4032kb

input:

10
11 97 -85 94
53 95 -18 93
63 95 31 99
71 100 -37 94
-28 92 -68 100
71 92 -97 95
97 96 72 94
34 97 -75 91
27 91 92 96
-39 99 17 100

output:

93.2678571429

result:

ok found '93.26786', expected '93.26786', error '0.00000'

Test #18:

score: 0
Accepted
time: 1ms
memory: 3772kb

input:

10
68 93 -37 90
-43 96 29 99
-75 91 19 90
87 93 -11 92
-12 100 90 98
58 93 25 97
45 96 -94 92
-18 100 -4 98
-98 93 -37 94
92 94 -54 90

output:

90.2021276596

result:

ok found '90.20213', expected '90.20213', error '0.00000'

Test #19:

score: 0
Accepted
time: 1ms
memory: 3676kb

input:

10
-100 96 25 91
-91 94 -36 92
-17 94 52 100
4 97 -68 91
59 96 -41 98
-49 90 -4 94
91 97 -63 94
-84 98 24 94
41 100 -41 98
6 100 -30 93

output:

92.0000000000

result:

ok found '92.00000', expected '92.00000', error '0.00000'