답안 #128791

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
128791 2019-07-11T09:31:51 Z baluteshih Dragon 2 (JOI17_dragon2) C++14
0 / 100
4000 ms 2164 KB
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define ALL(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define MEM(i,j) memset(i,j,sizeof i)
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;

const int B=200;
int bit[30005];
vector<pii> v[30005];

int Q(pii x)
{
	if(x.F<=0&&x.S<0) return 1;
	if(x.F>0&&x.S<=0) return 2;
	if(x.F>=0&&x.S>0) return 3;
	return 4;
}

bool yee(pii a,pii b)
{
	if(Q(a)!=Q(b)) return Q(a)<Q(b);
	return (ll)a.S*b.F<(ll)b.S*a.F;
}

bool yee2(pair<pii,pii> a,pair<pii,pii> b)
{
	return yee(a.F,b.F);
}

bool yee3(pii a,pii b)
{
	return !yee(a,b)&&!yee(b,a);
}

vector<pii> tb[30005];
pii operator-(const pii &a,const pii &b){return MP(a.F-b.F,a.S-b.S);}

ll ans[100005],m;

int main()
{jizz
	int n,q,x,y,c;
	pii a,b;
	cin >> n >> m;
	for(int i=0;i<n;++i)
		cin >> x >> y >> c,tb[c].pb(MP(x,y));
	cin >> a.F >> a.S >> b.F >> b.S >> q;
	if(a>b) swap(a,b);
	for(int i=0;i<q;++i)
	{
		cin >> x >> y;
		int as=0;
		for(auto j:tb[x])
			for(auto k:tb[y])
			{
				pii u=a-j,v=b-j,w=k-j;
				if(yee(v,u)) swap(u,v);
				if(Q(u)==1&&Q(v)==4)
					if((yee(w,u)||yee3(w,u))||(yee(v,w)||yee3(v,w))) ++as;
					else;
				else
					if((yee(u,w)||yee3(u,w))&&(yee(w,v)||yee3(w,v))) ++as;
					else;
			}
		cout << as << "\n";
	}
}
/*
4 2 
0 1 1
0 -1 1
1 2 2
-6 1 2
-2 0 2 0
2
1 2
2 1

3 2
-1000000000 -1 1
-999999998 -1 1
0 0 2
999999997 1 999999999 1
1
1 2

6 3
2 -1 1
1 0 1
0 3 2
2 4 2
5 4 3
3 9 3
0 0 3 3
6
1 2
1 3
2 1
2 3
3 1
3 2
*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 1956 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 4094 ms 2164 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 1956 KB Output isn't correct
2 Halted 0 ms 0 KB -