QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#470973#7862. Land Tradeucup-team052#RE 1009ms26708kbC++234.2kb2024-07-10 17:05:412024-07-10 17:05:41

Judging History

你现在查看的是最新测评结果

  • [2024-07-10 17:05:41]
  • 评测
  • 测评结果:RE
  • 用时:1009ms
  • 内存:26708kb
  • [2024-07-10 17:05:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define mod 998244353
#define ll long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define double long double
inline int read()
{
	char ch=getchar(); int nega=1; while(!isdigit(ch)) {if(ch=='-') nega=-1; ch=getchar();}
	int ans=0; while(isdigit(ch)) {ans=ans*10+ch-48;ch=getchar();}
	if(nega==-1) return -ans;
	return ans;
}
void print(vector<int> x){for(int i=0;i<(int)x.size();i++) printf("%d%c",x[i]," \n"[i==(int)x.size()-1]);}
#define N 305
#define M (N*N)
const double eps=1e-15;
char s[10005];
int bra[10005],st[10005],id[10005],tp;
int L,R,D,U,len,n;
typedef bitset<M> bs;
bs r[N];
int sgn(double x)
{
	if(x<0) return -1;
	else if(x>0) return 1;
	else return 0;
}
struct Vec
{
	double x,y;
	Vec(double a=0,double b=0) {x=a,y=b;}
	double norm() {return x*x+y*y;}
	double abs() {return sqrt(x*x+y*y);}
};
Vec rdvec()
{
	double x,y;
	scanf("%lf %lf",&x,&y);
	return Vec(x,y);
}
Vec operator + (const Vec &x,const Vec &y) {return Vec(x.x+y.x,x.y+y.y);}
Vec operator - (const Vec &x,const Vec &y) {return Vec(x.x-y.x,x.y-y.y);}
Vec operator * (const Vec &x,const double y) {return Vec(x.x*y,x.y*y);}
Vec operator / (const Vec &x,const double y) {return Vec(x.x/y,x.y/y);}
double dis(const Vec &x,const Vec &y) {return (x-y).abs();}
double dis(const Vec &x) {return sqrt(x.x*x.x+x.y*x.y);}
void print(Vec x) {printf("%.3lf %.3lf\n",x.x,x.y);}
double cdot(const Vec &x,const Vec &y) {return x.x*y.x+x.y*y.y;}
double cross(const Vec &x,const Vec &y) {return x.x*y.y-x.y*y.x;}
int ccw(const Vec &x,const Vec &y,const Vec &z)
{
	int w=sgn(cross(y-x,z-x));
	if(w==1) return 1; // ccw
	else if(w==-1) return -1; // cw;
	else return 0; // coline
}
struct Seg
{
	Vec s; double c; // ax+by+c>=0
	Seg(Vec x,double y=0) {s=x,c=y;}
	Seg() {}
	Seg flip() {return Seg(s*(-1),-c);}
};
Seg a[N];
vector<vector<Vec>> all,tmp;
vector<Vec> c;
vector<Vec> cut(vector<Vec> p,Seg s)
{
	vector<Vec> ans;
	for(int i=0;i<(int)p.size();i++)
	{
		double t1=cdot(p[i],s.s)+s.c,t2=cdot(p[(i+1)%(int)p.size()],s.s)+s.c;
		if(t1>=0) ans.push_back(p[i]);
		if(sgn(t1)*sgn(t2)<0)
		{
			double tv=t1/(t2-t1);
			Vec d=p[(i+1)%(int)p.size()]-p[i];
			Vec po=p[i]-(d*tv);
			assert(abs(cdot(s.s,po)+s.c)<eps);
			ans.push_back(po);
		}
	}
	return ans;
}
void init()
{
	vector<Vec> v;
	v.emplace_back(L,D);
	v.emplace_back(R,D);
	v.emplace_back(R,U);
	v.emplace_back(L,U);
	all.push_back(v);
	for(int i=1;i<=n;i++)
	{
		tmp=all; all.clear();
		Vec cv=a[i].s; double cc=a[i].c;
		for(auto v:tmp)
		{
			double mx=-1e9,mn=1e9;
			for(auto p:v)
			{
				double w=cdot(p,cv)+cc;
				mx=max(mx,w),mn=min(mn,w);
			}
			if(mx>0) all.push_back(cut(v,a[i]));
			if(mn<0) all.push_back(cut(v,a[i].flip()));
		}
	}
	// for(auto p:all)
	// {
		// for(auto v:p) print(v);
		// printf("\n");
	// }
	for(auto p:all)
	{
		Vec cc;
		for(auto v:p) cc=cc+v;
		cc=cc/(double)p.size();
		c.push_back(cc);
	}
}
bs solve(int l,int r)
{
	if(s[l]=='(')
	{
		assert(bra[l]==r);
		if(s[l+1]=='!')
		{
			bs t=solve(l+2,r-1);
			t.flip();
			return t;
		}
		else
		{
			int mid=bra[l+1]+1;
			bs L=solve(l+1,mid-1);
			bs R=solve(mid+1,r-1);
			if(s[mid]=='&') return L&R;
			else if(s[mid]=='|') return L|R;
			else if(s[mid]=='^') return L^R;
			else assert(0);
		}
	}
	else if(s[l]=='[')
	{
		bs t;
		for(int i=0;i<(int)all.size();i++)
		{
			int lid=id[l];
			if(cdot(a[lid].s,c[i])+a[lid].c>=0) t[i]=1;
		}
		return t;
	}
	else assert(0);
}
signed main()
{
	cin>>L>>R>>D>>U;
	scanf("%s",s+1); len=strlen(s+1);
	for(int i=1;i<=len;i++)
	{
		if(s[i]=='('||s[i]=='[') st[++tp]=i;
		if(s[i]==')'||s[i]==']')
		{
			int u=st[tp--];
			bra[i]=u,bra[u]=i;
		}
	}
	for(int i=1;i<=len;i++)
	{
		if(s[i]=='[')
		{
			n++;
			sscanf(s+i,"[%Lf,%Lf,%Lf]",&a[n].s.x,&a[n].s.y,&a[n].c);
			id[i]=n;
		}
	}
	init();
	assert((int)all.size()<M);
	bs ans=solve(1,len);
	double sum=0;
	for(int i=0;i<(int)all.size();i++)
	{
		if(ans[i])
		{
			for(int j=1;j+1<(int)all[i].size();j++) sum+=cross(all[i][j]-all[i][0],all[i][j+1]-all[i][0]);
		}
	}
	printf("%.10Lf\n",sum/2);
	return 0;
}



Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

0 1 0 1
([-1,1,0]^[-1,-1,1])

output:

0.5000000000

result:

ok found '0.5000000', expected '0.5000000', error '0.0000000'

Test #2:

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

input:

-5 10 -10 5
((!([1,2,-3]&[10,3,-2]))^([-2,3,1]|[5,-2,7]))

output:

70.4516934046

result:

ok found '70.4516934', expected '70.4516934', error '0.0000000'

Test #3:

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

input:

0 1 -1 1
([1,1,1]&[-1,-1,-1])

output:

0.0000000000

result:

ok found '0.0000000', expected '0.0000000', error '-0.0000000'

Test #4:

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

input:

0 1000 0 1000
(([1,-1,0]&[-1000,999,999])&([1,0,-998]&[0,1,-998]))

output:

0.0005000000

result:

ok found '0.0005000', expected '0.0005000', error '0.0000000'

Test #5:

score: 0
Accepted
time: 2ms
memory: 6596kb

input:

-725 165 643 735
((((!(([22,15,137]|(!([23,-5,-41]^(!([2,25,-515]&[-37,10,487])))))&(!(([25,24,47]^([-24,21,-114]^[19,-7,79]))^[4,20,241]))))^(!((!((!(([30,-1,474]^([14,17,155]^[-31,-6,-153]))|[-15,-15,108]))|(([-26,-11,421]&[-15,-3,-224])&[14,-3,458])))^[9,20,-404])))^(!((!((!(([14,-6,-464]^[-11,8,...

output:

47063.3348524415

result:

ok found '47063.3348524', expected '47063.3348524', error '0.0000000'

Test #6:

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

input:

767 957 738 941
((!(((!([3,-3,507]^[-30,-10,425]))^[-6,7,643])^((!((!([-11,0,450]^[21,17,-65]))&(!([17,0,64]^[-11,0,804]))))|[-31,10,-687])))&((!(([-34,12,-527]^(!([17,-14,-219]^(!([13,-27,-105]^(!([18,-47,-110]&(!([-9,-20,-455]^[-18,26,-228])))))))))^([-4,0,144]^[10,1,396])))^((!((!([35,0,-221]&[-5...

output:

36999.0586556632

result:

ok found '36999.0586557', expected '36999.0586557', error '0.0000000'

Test #7:

score: 0
Accepted
time: 1009ms
memory: 26708kb

input:

-513 213 -733 114
(!((!((!((((!([2,16,-57]|[15,40,-272]))^((!(([0,26,315]|[5,-4,-336])^(!([-12,2,218]&([17,-16,-730]&[-7,3,-263])))))^[18,-7,29]))^[5,30,-126])^((!(((!((([8,9,406]^(!([-26,6,63]^[-38,-25,108])))^(([-9,20,220]^(!([-2,-27,213]^[29,16,-269])))|[-12,-4,-586]))^([30,0,-443]|(!((!([-17,0,3...

output:

295728.6081036107

result:

ok found '295728.6081036', expected '295728.6081036', error '0.0000000'

Test #8:

score: 0
Accepted
time: 11ms
memory: 4748kb

input:

-517 -379 -789 477
(((!((!(([1,-12,191]^(!(((!([32,0,89]^[-35,6,33]))^[-3,6,-293])^[20,-39,77])))^(([16,15,-285]^[15,-7,430])^([20,3,-95]|(!((!(([-15,-27,339]^[-11,-13,221])^[33,28,596]))|([-17,21,402]^[22,16,90])))))))&(!((!((!([12,-1,-279]^[-30,-13,224]))^[-29,24,-33]))^([31,-19,288]^(!((!([-1,26,...

output:

107150.6048796972

result:

ok found '107150.6048797', expected '107150.6048797', error '0.0000000'

Test #9:

score: 0
Accepted
time: 7ms
memory: 4944kb

input:

-477 275 -266 519
(!((!((!((!([-1,3,162]|[-32,16,269]))&(!(((((([-31,7,114]^([-12,7,-163]^[23,-10,159]))|(!(([0,-16,114]^[-33,15,-190])|(!([1,-22,308]^[-31,13,316])))))^((!([-12,29,-22]^(([23,15,-8]^[0,15,46])^[6,15,356])))^[22,13,-163]))^([18,17,487]^[28,23,143]))|(!(((!((!(([7,-45,-583]&([31,2,-22...

output:

335169.3105175159

result:

ok found '335169.3105175', expected '335169.3105175', error '0.0000000'

Test #10:

score: -100
Runtime Error

input:

175 624 -835 683
(!(((!(([-32,30,-478]^[23,4,-120])^[28,33,413]))|(!((!((!((!([-15,-5,0]^(!((!(((!([0,-32,90]^[-9,-22,-7]))^[-10,-35,344])|(!([1,11,-235]|[-31,-6,-344]))))^(!((!([-15,0,-90]|[-17,-10,-153]))^[-1,6,-8]))))))^(!([8,-6,302]^[-2,4,91]))))|([13,28,-70]^[16,-11,-74])))^(((((!((!((([-5,8,45...

output:


result: