PivotOJ

Triple Peaks

시간 제한: 2000ms메모리 제한: 2048MB출처: IOI 2025BOJ 34215

문제

The Cordillera Oriental is a mountain range in the Andes that stretches across Bolivia. It consists of a sequence of NN mountain peaks, numbered from 00 to N1N - 1. The height of peak ii (0i<N0 \leq i < N) is H[i]H[i], which is an integer between 11 and N1N - 1, inclusive.

For any two peaks ii and jj where 0i<j<N0 \leq i < j < N, the distance between them is defined as d(i,j)=jid(i, j) = j - i.

According to ancient Inca legends, a triple of peaks is mythical if it has the following special property: the heights of the three peaks match their pairwise distances ignoring the order.

Formally, a triple of indices (i,j,k)(i, j, k) is mythical if

  • 0i<j<k<N0 \leq i < j < k < N, and
  • the heights (H[i],H[j],H[k])(H[i], H[j], H[k]) match the pairwise distances (d(i,j),d(i,k),d(j,k))(d(i,j), d(i,k), d(j,k)) ignoring the order. For example, for indices 0,1,20, 1, 2 the pairwise distances are (1,2,1)(1, 2, 1), so the heights (H[0],H[1],H[2])=(1,1,2)(H[0],H[1],H[2]) = (1,1,2), (H[0],H[1],H[2])=(1,2,1)(H[0],H[1],H[2]) = (1,2,1), and (H[0],H[1],H[2])=(2,1,1)(H[0],H[1],H[2]) = (2,1,1) all match them, but the heights (H[0],H[1],H[2])=(1,2,2)(H[0], H[1], H[2])=(1,2,2) do not match them.

This problem consists of two parts, with each subtask associated with either Part I or Part II. You may solve the subtasks in any order. In particular, you are not required to complete all of Part I before attempting Part II.

이 문제는 채점 준비 중입니다. 테스트 데이터가 확보되면 제출이 가능합니다.