#P3973. [TJOI2015] 线性代数

    ID: 2902 远端评测题 1000ms 128MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>2015各省省选图的建立,建图最大流最小割天津

[TJOI2015] 线性代数

Description

To improve her IQ, ZJY starts to study linear algebra.

Her friend Boluo gives her the following problem: Given an n×nn \times n matrix BB and a 1×n1 \times n matrix CC. Find a 1×n1 \times n 0-1 matrix AA such that D=(A×BC)×ATD = (A \times B - C) \times A^{\sf T} is maximized, where ATA^{\sf T} is the transpose of AA, and output DD.

Input Format

The first line contains an integer nn.
The next nn lines give matrix BB: in the ii-th line, the jj-th number is Bi,jB_{i,j}.
The next line contains nn integers, representing matrix CC.
Every number in matrices BB and CC is a non-negative integer not exceeding 10001000.

Output Format

Output a single integer, the maximum value of DD.

3
1 2 1
3 1 0
1 2 3
2 3 7
2

Hint

  • For 30%30\% of the testdata, n15n \leq 15.
  • For 100%100\% of the testdata, 1n5001 \leq n \leq 500.
  • There are also two extra unscored hack testdata in subtask 2, with the same ranges as above.

Translated by ChatGPT 5