QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#626751#5067. Two WallsCrysflyWA 0ms3636kbC++143.7kb2024-10-10 12:24:322024-10-10 12:24:33

Judging History

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

  • [2024-10-10 12:24:33]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3636kb
  • [2024-10-10 12:24:32]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2")
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
#define ull unsigned long long
#define int long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	return f?-x:x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 200005
#define inf 0x3f3f3f3f

typedef double db;
const db eps=1e-8,pi=3.14159265358979323846;
int sgn(int x){return x<0?-1:x>0;}
int cmp(int a,int b){return sgn(a-b);}

struct P{
	int x,y;
	P(int x=0,int y=0):x(x),y(y){}
	P&operator +=(P o){return x+=o.x,y+=o.y,*this;}
	P&operator -=(P o){return x-=o.x,y-=o.y,*this;}
	P&operator *=(int o){return x*=o,y*=o,*this;}
	P&operator /=(int o){return x/=o,y/=o,*this;}
	friend P operator +(P a,P b){return a+=b;}
	friend P operator -(P a,P b){return a-=b;}
	friend P operator *(P a,int b){return a*=b;}
	friend P operator /(P a,int b){return a/=b;}
	friend bool operator <(P a,P b){return fabs(a.x-b.x)<eps?a.y<b.y:a.x<b.x;}
	friend bool operator ==(P a,P b){return cmp(a.x,b.x)==0 && cmp(a.y,b.y)==0;}
	friend bool operator !=(P a,P b){return !(a==b);}
	friend int operator %(P a,P b){return a.x*b.x+a.y*b.y;} // dot
	friend int operator *(P a,P b){return a.x*b.y-a.y*b.x;} // cross
	
//	P rot(db o){
//		db s=sin(o),c=cos(o),xx=x*c-y*s,yy=x*s+y*c;
//		x=xx,y=yy;return *this;
//	}
	P rot90(){swap(x,y),x=-x;return *this;}
	db ang(){return atan2(y,x);}
	db len(){return sqrt(x*x+y*y);}
	int len2(){return x*x+y*y;}
	
	int half(){return sgn(y)==1||(sgn(y)==0&&sgn(x)>=0);}
//	P unit(){return ((*this))/len();}
	
	void read(){cin>>x>>y;}
	void out(){cout<<"("<<x<<","<<y<<")"<<endl;}
};
bool cmp_dir(P a,P b){
	if(a.half()!=b.half())return a.half()<b.half();
	return sgn(a*b)>0;
}

db dis(P a,P b){return (a-b).len();}
int cross(P a,P b,P c){
	// (a->b)*(a->c)
	return (b.x-a.x)*(c.y-a.y)-(b.y-a.y)*(c.x-a.x);
}
int cmp3(P a,P b,P c){
	return sgn(cross(a,b,c));
}

bool inter(int l1,int r1,int l2,int r2){
	if(l1>r1)swap(l1,r1); if(l2>r2)swap(l2,r2);
	return !(cmp(r1,l2)==-1||cmp(r2,l1)==-1);
}
bool ismid(int a,int m,int b){
	return sgn(a-m)==0||sgn(b-m)==0||((a<m)!=(b<m));
}
bool ismid(P a,P m,P b){
	return ismid(a.x,m.x,b.x)&&ismid(a.y,m.y,b.y);
}

bool isseg(P p1,P p2,P q1,P q2){
	return inter(p1.x,p2.x,q1.x,q2.x) && inter(p1.y,p2.y,q1.y,q2.y) &&
	cmp3(p1,p2,q1)*cmp3(p1,p2,q2)<=0 && cmp3(q1,q2,p1)*cmp3(q1,q2,p2)<=0;
}
bool isseg_strict(P p1,P p2,P q1,P q2){
	return cmp3(p1,p2,q1)*cmp3(p1,p2,q2)<0 && cmp3(q1,q2,p1)*cmp3(q1,q2,p2)<0;
}

bool paral(P p1,P p2,P q1,P q2){
	// is parallel
	return sgn((p2-p1)*(q2-q1))==0;
}
bool isray(P p1,P p2,P q1,P q2){
	if(paral(p1,p2,q1,q2)) return 0;
	int s1=cross(q1,q2,p1),s2=-cross(q1,q2,p2);
	if(s1+s2<0) s1=-s1,s2=-s2;
	return s1<0;
}

int work()
{
	P a,b,c,d,e,f;
	a.read(),b.read(),c.read(),d.read(),e.read(),f.read();
	if(!isseg(a,b,c,d) && !isseg(a,b,e,f)) return 0;
	if(!isseg_strict(a,b,c,d) || !isseg_strict(a,b,e,f)) return 1;
	
	if(cmp3(a,c,d)>0)swap(c,d);
	if(cmp3(a,e,f)>0)swap(e,f);
	
	if(isray(a,b,c,e)) return 1;
	if(isray(a,b,d,f)) return 1;
	return 2;
}

signed main()
{
	int T=read();
	while(T--)cout<<work()<<"\n";
	return 0;
}

/*

*/

详细

Test #1:

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

input:

3
0 0
1 1
2 2 3 3
4 4 5 5
0 0
1 1
2 2 3 3
2 2 3 3
0 0
10 10
10 0 0 10
1 1 2 2

output:

0
0
1

result:

ok 3 number(s): "0 0 1"

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3616kb

input:

2
-999999999 999999998
999999999 999999998
-1000000000 -1000000000 1000000000 1000000000
1000000000 -1000000000 -1000000000 1000000000
-999999999 999999998
999999999 999999998
-999999998 -999999998 1000000000 1000000000
999999998 -999999998 -1000000000 1000000000

output:

2
2

result:

wrong answer 2nd numbers differ - expected: '1', found: '2'