No.2320 Game World for PvP
タグ : / 解いたユーザー数 67
作問者 : 👑
amentorimaru
/ テスター :
tatyam
Problem Statement
$N$ users of a virtual space, numbered $1,2,\dots N$, are going to play a game in which they split into $2$ avatar teams: Team Etowanyu and Team Rataryuru. Sounds fun, and how cute.
Currently, users $E_1,E_2,\dots ,E_S$ are on Team Etowanyu and users $R_1,R_2,\dots R_T$ are on Team Rataryuru, and the remaining users are about to decide which team to join.
In this game, the better the teamwork, the more interesting the match tends to be for both sides, and the fun is not significantly affected by things like a difference in the number of players.
When user $i$ and user $j$ are on the same team, they can demonstrate a teamwork power of $C_{ij}$.
Find the maximum possible total teamwork power that can be produced by assigning the teams appropriately, so that the Etowanyu-kuns and Rataryuru-kuns can enjoy the game.
Input
$N\ S \ T$
$E_1 \ E_2 \ \dots \ E_S$
$R_1 \ R_2 \ \dots \ R_T$
$C_{11} \ C_{12} \dots \ C_{1N}$
$C_{21} \ C_{22} \dots \ C_{2N}$
$\vdots$
$C_{N1} \ C_{N2} \dots \ C_{NN}$
- All input values are integers.
- $2 \le N \le 60$
- $1 \le S,T \le N-1$
- $S+T \le N$
- $1 \le E_i,R_i \le N$
- $0 \le C_{ij} \le 10^9$
- $C_{ij}=C_{ji}$
- $C_{ii}=0$
- All $E_i,R_i$ are pairwise distinct.
Output
Output the maximum possible total teamwork power.
Sample
Sample 1
Input
4 1 1 1 4 0 4 2 1 4 0 1 2 2 1 0 5 1 2 5 0
Output
9
From the start, user $1$ is on Team Etowanyu and user $4$ is on Team Rataryuru.
If user $2$ joins Team Etowanyu and user $3$ joins Team Rataryuru, a teamwork power of $4$ is demonstrated between the Etowanyu-kuns, users $1,2$, and a teamwork power of $5$ is demonstrated between the Rataryuru-kuns, users $3,4$.
The total teamwork power is $9$, and this is the maximum.
Sample 2
Input
4 2 2 1 2 3 4 0 1 9 9 1 0 9 9 9 9 0 1 9 9 1 0
Output
2
The teams are already decided from the start.
Sample 3
Input
5 1 2 1 4 5 0 0 0 0 0 0 0 9 9 9 0 9 0 9 9 0 9 9 0 9 0 9 9 9 0
Output
54
User $1$ plays a cute Etowanyu-kun all alone.
Sample 4
Input
10 2 3 2 8 7 10 6 0 15 6 23 28 14 27 26 6 13 15 0 11 23 14 12 27 27 11 1 6 11 0 28 0 1 13 15 13 17 23 23 28 0 4 19 15 12 29 12 28 14 0 4 0 30 19 14 3 28 14 12 1 19 30 0 17 7 0 8 27 27 13 15 19 17 0 10 18 29 26 27 15 12 14 7 10 0 4 18 6 11 13 29 3 0 18 4 0 14 13 1 17 12 28 8 29 18 14 0
Output
461
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。