CF1168C.And Reachability
普及/提高-
通过率:0%
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
Toad Pimple has an array of integers a1,a2,…,an .
We say that y is reachable from x if x<y and there exists an integer array p such that x=p1<p2<…<pk=y , and api&api+1>0 for all integers i such that 1≤i<k .
Here & denotes the bitwise AND operation.
You are given q pairs of indices, check reachability for each of them.
输入格式
The first line contains two integers n and q ( 2≤n≤300000 , 1≤q≤300000 ) — the number of integers in the array and the number of queries you need to answer.
The second line contains n space-separated integers a1,a2,…,an ( 0≤ai≤300000 ) — the given array.
The next q lines contain two integers each. The i -th of them contains two space-separated integers xi and yi ( 1≤xi<yi≤n ). You need to check if yi is reachable from xi .
输出格式
Output q lines. In the i -th of them print "Shi" if yi is reachable from xi , otherwise, print "Fou".
输入输出样例
输入#1
5 3 1 3 0 2 1 1 3 2 4 1 4
输出#1
Fou Shi Shi
说明/提示
In the first example, a3=0 . You can't reach it, because AND with it is always zero. a2&a4>0 , so 4 is reachable from 2 , and to go from 1 to 4 you can use p=[1,2,4] .