Longest Trip

아직 제출이 없습니다시간 제한1초메모리 제한1024 MB

문제

The IOI 2023 organizers are in big trouble! They forgot to plan the trip to Ópusztaszer for the upcoming day. But maybe it is not yet too late ...

There are $N$ landmarks at Ópusztaszer indexed from $0$ to $N-1$. Some pairs of these landmarks are connected by bidirectional roads. Each pair of landmarks is connected by at most one road. The organizers don't know which landmarks are connected by roads.

We say that the density of the road network at Ópusztaszer is at least $\delta$ if every $3$ distinct landmarks have at least $\delta$ roads among them. In other words, for each triplet of landmarks $(u, v, w)$ such that $0 \le u \lt v \lt w \lt N$, among the pairs of landmarks $(u,v), (v,w)$ and $(u,w)$ at least $\delta$ pairs are connected by a road.

The organizers know a positive integer $D$ such that the density of the road network is at least $D$. Note that the value of $D$ cannot be greater than $3$.

The organizers can make calls to the phone dispatcher at Ópusztaszer to gather information about the road connections between certain landmarks. In each call, two nonempty arrays of landmarks $[A[0], \ldots, A[P-1]]$ and $[B[0], \ldots, B[R-1]]$ must be specified. The landmarks must be pairwise distinct, that is,

  • $A[i] \neq A[j]$ for each $i$ and $j$ such that $0 \le i \lt j \lt P$;
  • $B[i] \neq B[j]$ for each $i$ and $j$ such that $0 \le i \lt j \lt R$;
  • $A[i] \neq B[j]$ for each $i$ and $j$ such that $0 \le i \lt P$ and $0\le j \lt R$.

For each call, the dispatcher reports whether there is a road connecting a landmark from $A$ and a landmark from $B$. More precisely, the dispatcher iterates over all pairs $i$ and $j$ such that $0 \le i \lt P$ and $0\le j \lt R$. If, for any of them, the landmarks $A[i]$ and $B[j]$ are connected by a road, the dispatcher returns true. Otherwise, the dispatcher returns false.

A trip of length $l$ is a sequence of distinct landmarks $t[0], t[1], \ldots, t[l-1]$, where for each $i$ between $0$ and $l-2$, inclusive, landmark $t[i]$ and landmark $t[i+1]$ are connected by a road. A trip of length $l$ is called a longest trip if there does not exist any trip of length at least $l+1$.

Your task is to help the organizers to find a longest trip at Ópusztaszer by making calls to the dispatcher.

제한

  • $3 \le N \le 256$
  • The sum of $N$ over all calls to longest_trip does not exceed $1\,024$ in each test case.
  • $1 \le D \le 3$