308279: CF1492E. Almost Fault-Tolerant Database
Memory Limit:512 MB
Time Limit:2 S
Judge Style:Text Compare
Creator:
Submit:0
Solved:0
Description
Almost Fault-Tolerant Database
题意翻译
给定 $n$ 个长度为 $m$ 的序列 $a$,构造一个序列 $s$,满足 $\forall \ 1 \le i \le m,s_i\in[1,10^9]$。 且对于任意序列,$\sum_{i=1}^{m}[a_i\ne s_i]\le 2$。若有多组解,输出任意一组均可;若无解,输出 `No`。 对于 $100\%$ 的数据,$n \ge 2,\ m \ge 1,\ n⋅m\le2.5\times10^5$。题目描述
You are storing an integer array of length $ m $ in a database. To maintain internal integrity and protect data, the database stores $ n $ copies of this array. Unfortunately, the recent incident may have altered the stored information in every copy in the database. It's believed, that the incident altered at most two elements in every copy. You need to recover the original array based on the current state of the database. In case there are multiple ways to restore the array, report any. If there is no array that differs from every copy in no more than two positions, report that as well.输入输出格式
输入格式
The first line contains integers $ n $ and $ m $ ( $ 2 \le n $ ; $ 1 \le m $ ; $ n \cdot m \le 250\,000 $ ) — the number of copies and the size of the array. Each of the following $ n $ lines describes one of the currently stored copies in the database, it consists of $ m $ integers $ s_{i, 1}, s_{i, 2}, \dots, s_{i, m} $ ( $ 1 \le s_{i, j} \le 10^9 $ ).
输出格式
If there is an array consistent with all given copies, print "Yes" and then the array itself. The array must have length $ m $ and contain integers between $ 1 $ and $ 10^9 $ only. Otherwise, print "No". If there are multiple possible arrays, print any of them.
输入输出样例
输入样例 #1
3 4
1 10 10 100
1 1 1 100
10 100 1 100
输出样例 #1
Yes
1 10 1 100
输入样例 #2
10 7
1 1 1 1 1 1 1
1 1 1 1 1 1 2
1 1 1 1 1 2 2
1 1 1 1 2 2 1
1 1 1 2 2 1 1
1 1 2 2 1 1 1
1 2 2 1 1 1 1
2 2 1 1 1 1 1
2 1 1 1 1 1 1
1 1 1 1 1 1 1
输出样例 #2
Yes
1 1 1 1 1 1 1
输入样例 #3
2 5
2 2 1 1 1
1 1 2 2 2
输出样例 #3
No