問題一覧 > スコア問題

No.5016 Worst Mayor

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / リアクティブ問題 (詳しくはこちら)
タグ : (解説公開後に AC するまで非表示) / 解いたユーザー数 47
作問者 : e869120 / テスター : butsurizuki trineutron
お気に入りにしたユーザー ProblemId : 9554 / 自分の提出
問題文最終更新日: 2023-04-29 13:50:15
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Show the original
yukicoder score contest 5 (順位表) の他の問題:

Problem Statement

KYOPRO City is a square-shaped city with $14$ rows and $14$ columns.
The block in the $i$-th row from the north and the $j$-th column from the west is numbered $(i, j)$, and blocks adjacent to the east, west, south, or north are connected by roads.
In other words, the structure of KYOPRO City is as shown in the figure below.

Also, $N$ citizens live in KYOPRO City, numbered from $1$ to $N$.
The home of citizen $k$ is in block $(A_k, B_k)$, and their company is in block $(C_k, D_k)$.


Initially, all roads built in KYOPRO City are ordinary roads, and it takes $1$ minute to travel along one road.
So the mayor, Taro, decided to shorten travel times by upgrading some roads to highways (which can be traveled in $0.223$ minutes).

Specifically, over the remaining $T$ days of his term, he performs the following actions in order each day.
Initially, he has $10^6$ yen in funds and $1$ collaborator.

  1. Choose one of the following actions
    • Build a highway: make the road connecting blocks $(x, y)$ and $(z, w)$ a highway. This costs $\lfloor 10^7 \div \sqrt{[協力者数]} \rfloor$ yen, where [協力者数] is the number of collaborators
    • Gather collaborators: the number of collaborators increases by $1$
    • Raise funds: the money he has increases by $50000$ yen
  2. Receive the highway revenue
    • It costs $30$ yen to travel along one highway, and every citizen always commutes in the shortest possible time
    • Therefore, letting $s_k$ be the number of highways on the shortest route from the home to the company of citizen $k$ ($1 \leqq k \leqq N$), he receives $60(s_1 + \cdots + s_N)$ yen

Taro's true goal is neither to make the city more convenient nor to make its finances healthy, but to make money, so he wants to have as much money as possible in the end.
Output Taro's actions so that his final amount of money is as large as possible.

Notes

There may be various routes that each citizen could take in step 2.,
but note that under the constraints of this problem, the number of highways traveled on a shortest-time route is unique.

For example, when the yellow roads in the image below are highways, there are $2$ ways to travel from S to T in the shortest time ($4.338$ minutes),
but both of them use $6$ highways.


Input and Output

This is an interactive problem. Note that the input and output format differs from that of ordinary problems.

First, your program must receive $N+1$ lines of input in the following format.

$N$ $T$
$A_1$ $B_1$ $C_1$ $D_1$
$A_2$ $B_2$ $C_2$ $D_2$
 $:$
$A_N$ $B_N$ $C_N$ $D_N$

Next, repeat (a) and (b), in that order, $T$ times.

(a) Letting $u$ be the current amount of money and $v$ be the current number of collaborators, your program must receive input in the following format.

$u$ $v$

(b) Output Taro's action.
To build a highway connecting block $(x, y)$ and block $(z, w)$, output in the following format.
Note that $|x - z| + |y - w| = 1$ must hold.

$1$ $x$ $y$ $z$ $w$

To gather collaborators, output in the following format.

$2$

To raise funds, output in the following format.

$3$

Constraints

  • $N=3000$
  • $T=400$
  • $1 \leqq A_k, B_k, C_k, D_k \leqq 14$ ($1 \leqq k \leqq N$)
  • Note that $(A_k, B_k) = (C_k, D_k)$ may hold

Scoring

Taro's final amount of money is directly your score. For example, if the final amount of money is $5$ hundred million yen, you get $5$ hundred million points.
However, if your output is invalid, it is judged as WA. Invalid output means any of the following.

  • The output does not follow the output format
  • A highway is built without sufficient funds
  • An attempt is made to build a highway connecting block $(x, y)$ and block $(z, w)$, but $|x-z| + |y-w| = 1$ is not satisfied
  • An attempt is made to build a highway connecting block $(x, y)$ and block $(z, w)$, but $1 \leqq x, y, z, w \leqq 14$ is not satisfied

If your program produces invalid output at some point, it will receive the input -1 -1 in (a) of the Input and Output section on the next turn, so terminate the program immediately.
If the program does not terminate, the judging result may be another error such as TLE or RE.
Note that attempting to build a highway where one has already been built is not judged as incorrect, but it is wasteful.

There are $50$ test cases in total, and the sum of the scores over all test cases is the score of a submission.
The final ranking is determined by the highest score obtained during the contest, and no system test is performed after the contest ends.

Sample Code / Hints

Heuristic beginners are recommended to read this section.

First, for those who are not familiar with interactive problems, sample code in C++ and Python is given below.
This program raises funds on every day.

Also, note that in this problem you receive the "current funds" and the "current number of collaborators" as input,
so you do not necessarily need to compute the "amount of highway revenue" yourself.

Test Case Generation

Note that this section is not essential for understanding the problem.

Test cases are generated by the following method.

  1. For each $(p, q)$ ($1 \leqq p \leqq 14, 1 \leqq q \leqq 14$), generate a random number $e_{p, q}$ with mean $0$ and standard deviation $1$
  2. For each $k$ ($1 \leqq k \leqq N$), generate $(A_k, B_k)$. The probability that $(A_k, B_k) = (p, q)$ is proportional to $3^{e_{p,q}}$
  3. For each $k$ ($1 \leqq k \leqq N$), generate $(C_k, D_k)$. The probability that $(C_k, D_k) = (p, q)$ is proportional to $3^{e_{p,q}}$

Sample

Note that, unlike the constraints, this sample has $N=5, T=4$, and the initial amount of money is $2000$ × 10,000 yen.

Sample 1
Input to the program Output of the program
5 4
1 1 14 14
2 2 13 13
3 3 12 12
4 4 11 11
5 5 10 10
20000000 1
2
20000000 2
3
20050000 2
1 4 4 5 4
12979173 2
3

The final score is $13,029,413$ points.
Citizens $1, 2, 3, 4$ use the highway built on turn $3$ when commuting, so
the amount of money at the start of turn 4 is $20,050,000 - \lfloor 10,000,000 \div \sqrt{2} \rfloor + (60 \times 4) = 12,979,173$ yen.

Sample 2
Input to the program Output of the program
5 4
1 1 14 14
2 2 13 13
3 3 12 12
4 4 11 11
5 5 10 10
20000000 1
4
-1 -1

Note that if the user produces invalid output, the input -1 -1 is received.
The test case itself is the same as in Sample 1.

Other Samples

An example of a test case satisfying the constraints is given below. Note that the input consists only of $N, T, A_k, B_k, C_k, D_k$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。