Bitsets
시간 제한3초메모리 제한2048 MB
생성된 각 구간 질의마다 구간 안 모든 비트셋이 0이고 적어도 하나는 1인 위치의 개수를 세어 k개 질의의 합을 구한다.
문제
Let us consider the following operations on bitsets of size :
- . Here, if both and are equal to . Otherwise, .
- . Here, if either or is equal to . Otherwise, .
- . Here, if exactly one of and is equal to . Otherwise, .
- . Here, if is equal to . Otherwise, .
You are given an array of bitsets . Write a program that can answer queries of the following form:
- Take two integers and .
- Find bitset using the formula: .
- Count the number of ones in bitset : it is the answer.
입력
The first line contains two integers and (; ). The following lines describe the bitsets, where each line consists of characters and representing the bits of that bitset.
The next line of the input contains a single integer (), which denotes the number of queries. The following line contains three integers , , and ().
The queries are generated using pseudo-random numbers, with input parameters , , and , and a sequence of answers to the queries. Define two sequences and as follows:
- .
- .
- For , .
- For , .
For each query , the parameters and are defined as and .
출력
Output a single integer: the sum of the answers for all queries.
힌트
The queries are listed below: