Suspicious Reports (Basic)
InterviewTime limit1sMemory limit1024 MB
Given a full report s and a pattern t, decide whether t is the upper slice of s at some level h, and output the matching column indices.
- Level
Easy3 of 10
- Topics
- Brute force, Implementation, Array
- Solved
- No attempts yet
Statement
Eddie Brock is a journalist after all. Before he met Venom, he was writing a scathing article exposing every vice of the Life Foundation (yes, we are going back to the first movie again, but what can you do). Now he is looking at recently found financial reports of the Foundation and tracing traces of its illegal activity (for example, experiments on people).
Each report is an array of numbers of size , drawn as a histogram: a set of columns with the corresponding heights. The accountant marks which columns correspond to illegal operations as follows.
- First, he picks a segment of the histogram from to that contains records of the most illegal operations, located in columns .
- Then he draws a horizontal strip at height (possibly negative) between columns and inclusive, so that all columns of the illegal operations, being the most costly ones, are strictly above the strip, and the legal ones are not above it. Formally, the condition must be equivalent to .
- Then he saves the report of illegal operations in a secret folder as a sequence of length with . Informally, this is the upper part of a slice of the original histogram at level .
Eddie has a reliable full report and a separate report of illegal operations, sent by an anonymous source. The source claims that this report of illegal operations was obtained from the full report in the way described. Eddie only wants to know which exact columns of the full report correspond to the illegal operations.
Consider some examples. First the Foundation's full report, then the histogram of illegal operations:


In every example except the second, you can pick out a subsequence of columns whose heights sit at the given levels relative to the same horizontal cut, while the remaining columns lie below it. In the second example this is impossible, because one extra column is above the cut. Note that and do not have to hold.
Input
The first line contains an integer , the length of the report of illegal operations ().
The second line contains space-separated integers , the column heights of the report of all illegal operations of the Foundation ().
The third line contains an integer , the length of the Foundation's full report ().
The next line contains space-separated integers , the entries of the full report.
Output
On the first line, print YES (without quotes) if the report of illegal operations could indeed have been obtained from the given full report in the described way, and NO otherwise.
If YES is printed, the second line must contain space-separated integers , the indices of the columns in the full report that correspond to the Foundation's illegal operations ().