QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#21240. 哞樂致病

Statistics

大家都知道乳牛愛聽各種音樂——準確說是幾乎各種。偉大的乳牛作曲家 Wolfgang Amadeus Moozart 曾發現一種和弦常令乳牛很不舒服,稱為反芻七和弦,所以乳牛音樂通常避開它。

Farmer John 不懂乳牛音樂史的細節,決定用牛棚揚聲器播放最愛的歌。請找出其中所有反芻七和弦,估計乳牛會多不舒服。

歌曲有 $N$ 個音符,$1 \le N \le 20,000$,各是 $1..88$ 整數。反芻七和弦有 $C$ 個互異音符,$1 \le C \le 10$,也是 $1..88$ 整數。全部升降相同量(移調)或重排仍是這種和弦!若 $4,6,7$ 是,$3,5,6$(移調 $-1$)、$6,8,9$(移調 $+2$)、$6,4,7$(重排)、$5,3,6$(移調且重排)也都是。

反芻七和弦是符合條件的連續 $C$ 個音符,因此由歌曲中的起點唯一確定。求所有起始位置編號。

輸入格式

  • 第 $1$ 行:整數 $N$。

  • 第 $2..1+N$ 行:FJ 歌曲的 $N$ 個音符,每行一個。

  • 第 $2+N$ 行:整數 $C$。

  • 第 $3+N..2+N+C$ 行:示例和弦的 $C$ 個音符,所有移調和/或重排也都是反芻七和弦。

輸出格式

  • 第 $1$ 行:歌曲中和弦數量 $K$。不同出現可重疊。

  • 第 $2..1+K$ 行:每行一個起始編號($1$ 是首音符,$N$ 是末音符),按遞增順序。

範例

輸入格式 1

6
1
8
5
7
9
10
3
4
6
7

輸出格式 1

2
2
4

說明

歌曲是 $1,8,5,7,9,10$。和弦是 $4,6,7$ 的移調或重排。

出現兩個和弦,重疊一個音符。第一個是 $2$ 開始的 $8,5,7$(移調 $+1$ 並重排),第二個是 $4$ 開始的 $7,9,10$(移調 $+3$)。

題目作者:Rob Seay

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.