原题链接
本题需要注意按照官网的数据范围是可能爆int的,不过官网的数据比较水,int也给过,下面代码用了long来存。int最大值大约为2e9;
import java.util.Scanner;
public class Main {
static Node[] nds;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int m = sc.nextInt();
nds = new Node[n];
for (int i = 0; i < n; i++) {
int x = sc.nextInt();
int y = sc.nextInt();
char type = sc.nextLine().trim().charAt(0);
nds[i] = new Node(x, y, type);
}
for (int i = 0; i < m; i++) {
int a, b, c;
a = sc.nextInt();
b = sc.nextInt();
c = sc.nextInt();
if (judge(a, b, c))
System.out.println("Yes");
else
System.out.println("No");
}
sc.close();
}
private static boolean judge(int a, int b, int c) {
boolean type = true;// A在上面
if (a + b * nds[0].x + c * nds[0].y > 0) {
if (nds[0].type == 'B')
type = false;
} else {
if (nds[0].type == 'A')
type = false;
}
for (int i = 1; i < nds.length; i++) {
if (a + b * nds[i].x + c * nds[i].y > 0) {
if(nds[i].type=='A'&&type)continue;
if(nds[i].type=='B'&&!type)continue;
return false;
}else{
if(nds[i].type=='B'&&type)continue;
if(nds[i].type=='A'&&!type)continue;
return false;
}
}
return true;
}
static class Node {
long x, y;
char type;
public Node(long x, long y, char type) {
this.x = x;
this.y = y;
this.type = type;
}
}
}