Intelligence Exploration
InterviewTime limit4sMemory limit1024 MB
Given a 0/1 array, answer queries with the left-to-right implication value over each subarray from position l to r.
- Level
Medium4 of 10
- Topics
- Array, Math, Implementation
- Solved
- No attempts yet
Problem
John is a researcher in artificial intelligence. He wants to analyze the reasoning ability of a new Limitless Logic Machine and check how well it understands when one statement implies another.
The experiment uses a long array of length consisting of zeroes and ones. Each query is given as a pair , , and the machine must compute the value of the implication over the subarray . You must compute the correct answers to these queries so that John can validate the machine.
The implication operator is defined as follows.
The operations are evaluated from left to right, so the order is .
Input
The first line contains an integer (), the size of the array.
The second line contains integers (), the values in the array.
The third line contains an integer (), the number of queries.
Each of the next lines contains two integers and (), describing a query.
Output
For each query, print the result of the corresponding implication on its own line.