题目链接:http://codeforces.com/gym/100624/attachments
题目大意:在二维平面,有n条直线将平面划分成若干各区域,有m个点,问是不是在每个区域都至少存在一个点? n<=100 m<= 50000,保证没有三条直线交于同一点,没有两条相同的直线!
解题思路:先暴力的算出有多少个区域:假设已经有了i 条直线,现在算第i+1 条直线划分下去将增加多少区域,其实就是前i 条直线里面与第 i+1 条直线相交的个数+1 。
然后,对于每一个点算出它在每一条直线的左边还是右边(左边用0表示 右边用1 表示),用两个long long 来存,然后数一下有多少个所在区域不同的点,与区域数目进行比较
我写错的地方是:第一,一开始我用string 表示的01串;第二,1<<50是会爆掉int的,必须写成 1LL<<50。(太久没有写代码了。。。。)
//#pragma comment(linker,"/STACK:102400000,102400000")
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<string>
#define ll long long
#define db double
#define PB push_back
#define lson k<<1
#define rson k<<1|1
using namespace std;
const int N = 105;
const int M = 50005;
const db eps = 1e-8;
struct Point
{
ll x, y;
Point(db _x = 0, db _y = 0): x(_x), y(_y) {}
void input()
{
scanf("%I64d%I64d", &x, &y);
}
db operator * (const Point &t) const
{
return x * t.y - y * t.x;
}
Point operator - (const Point &t) const
{
return Point(x - t.x, y - t.y);
}
} p[M];
struct Line
{
ll a, b, c;
void input()
{
scanf("%I64d%I64d%I64d", &a, &b, &c);
}
} l[N];
bool parallel(const Line &l1, const Line &l2)
{
return l1.a * l2.b == l1.b * l2.a;
}
int n, m;
const int BASE = 50;
struct node
{
ll a[2];
node()
{
a[0] = a[1] = 0LL;
}
void setbit(int k)
{
a[k / BASE] |= 1LL << (k % BASE);
}
void setzero()
{
a[0] = a[1] = 0LL;
}
bool operator < (const node &t) const
{
return a[0] < t.a[0] || (a[0] == t.a[0] && a[1] < t.a[1]);
}
} seq[M];
int main()
{
#ifdef PKWV
freopen("in.in", "r", stdin);
#endif // PKWV
int T;
scanf("%d", &T);
while(T--)
{
scanf("%d%d", &n, &m);
int numb(0);
for(int i = 0; i < n; i++)
{
l[i].input();
int cnt(0);
for(int j = 0; j < i; j++)
if(!parallel(l[i], l[j])) cnt++;
numb += cnt + 1;
}
numb += 1;
for(int i = 0; i < m; i++)
{
p[i].input();
seq[i].setzero();
for(int j = 0; j < n; j++)
{
ll k = p[i].x * l[j].a + p[i].y * l[j].b + l[j].c;
if(k > 0) seq[i].setbit(j);
}
}
sort(seq, seq + m);
int cnt(1);
for(int i = 1; i < m; i++)
if(seq[i].a[0] != seq[i - 1].a[0] || seq[i].a[1] != seq[i - 1].a[1]) cnt++;
if(cnt == numb) printf("PROTECTED\n");
else printf("VULNERABLE\n");
}
return 0;
}