编程介的小学生 2017-10-27 15:41 采纳率: 20.5%
浏览 856
已采纳

Price List Strike Back

Problem Description
There are n shops numbered with successive integers from 1 to n in Byteland. Every shop sells only one kind of goods, and the price of the i-th shop's goods is vi. The distance between the i-th shop and Byteasar's home is di.

Every day, Byteasar will purchase some goods. On the i-th day, he will choose an interval [li,ri] and an upper limit ci. Then, he will visit each shop with distance at most ci away from home in [li,ri], buy at most one piece of goods from each shop and go back home. Of course, he can also choose to buy nothing. Back home, Byteasar will calculate the total amount of money he has costed that day and write it down on his account book, denoted as sumi.

However, due to Byteasar's poor math, he may calculate it wrong.

Please write a program to help Byteasar judge whether each number is sure to be calculated wrong.

Input
The first line of the input contains an integer T (1≤T≤10), denoting the number of test cases.

In each test case, the first line of the input contains two integers n,m (1≤n≤20000,1≤m≤100000), denoting the number of shops and the number of records on Byteasar's account book.

The second line of the input contains n integers v1,v2,...,vn (1≤vi≤100), denoting the price of the i-th shop's goods.

The third line of the input contains n integers d1,d2,...,dn (1≤di≤109), denoting the distance between the i-th shop and Byteasar's home.

Each of the next m lines contains four integers li,ri,ci,sumi (1≤li≤ri≤n,1≤ci≤109,1≤sumi≤100), denoting a record on Byteasar's account book.

Output
For each test case, print a line with m characters. If the i-th number is sure to be calculated wrong, then the i-th character should be '1'. Otherwise, it should be '0'.

Sample Input
2
3 3
3 3 3
2 4 3
3 3 5 3
3 3 3 1
2 3 1 3
5 4
5 1 2 4 2
1 8 9 2 1
1 5 1 3
4 4 1 5
1 5 3 5
1 3 5 1

Sample Output
011
1101

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-11-14 10:43
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥35 平滑拟合曲线该如何生成
  • ¥100 c语言,请帮蒟蒻写一个题的范例作参考
  • ¥15 名为“Product”的列已属于此 DataTable
  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 自己瞎改改,结果现在又运行不了了
  • ¥15 链式存储应该如何解决
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站