Can someone help me with Sereja And Table please.
PS: I didn't understand the editorial.
# | User | Rating |
---|---|---|
1 | tourist | 3985 |
2 | jiangly | 3814 |
3 | jqdai0815 | 3682 |
4 | Benq | 3529 |
5 | orzdevinwang | 3526 |
6 | ksun48 | 3517 |
7 | Radewoosh | 3410 |
8 | hos.lyric | 3399 |
9 | ecnerwala | 3392 |
9 | Um_nik | 3392 |
# | User | Contrib. |
---|---|---|
1 | cry | 169 |
2 | maomao90 | 162 |
2 | Um_nik | 162 |
4 | atcoder_official | 161 |
5 | djm03178 | 158 |
6 | -is-this-fft- | 157 |
7 | adamant | 155 |
8 | awoo | 154 |
8 | Dominater069 | 154 |
10 | luogu_official | 150 |
Can someone help me with Sereja And Table please.
PS: I didn't understand the editorial.
Name |
---|
Case 1: After change the table, there is at least row unchanged:
Iterate that row, then use this row to calculate minimal cost of other rows.
Case 2: After change the table, every rows changed:
There is at most k rows changed => m<=k => try 2^m state of first column => other column is same with first one or same with the inverted first column.
Thank you for your response. But i still don't understand your solution completely. What do do you mean after change of the table for example. Please try to give some small cases that illustrate your ideas, that will be very helpful.
Do you have trouble about Case 1 or Case 2?
Before showing you some example, we will talking about some properties.
Property 1: After executing operators (our table becomes expected table), suppose that we have row X[] and row Y[] (consider X and Y as arrays), there are only two cases: (1): X==Y or (2): X==^Y (^Y means change Y[i] into 1-Y[i]).
For example:
Notes that Property 1 is still right with columns, not only rows.
Property 2: If we "invert" a row on table (choose a row X and let X=^X), our table is still meet required conditions.
For example, invert row 2 in above example:
Note that Property 2 is right not only with rows, but also columns.
Now, let's talking about Case 1 and Case 2.
Example for Case 1:
Case 1 means there is some row is unmodified through operators.
Iterate i from 1 to row count, assume that i=2 (Row[i] = 010001). Choose Row[2] as a unmodified row.
Row[1] has two choices, (1): ==Row[2] and (2): ==^Row[2]. First choice is better (Cost=1). And second choice is worse, Cost=5. So if Row[2] is not modified, Row[1] must be 010001.
It is the same idea with Row[3], and Row[4].
Example for Case 2:
Try all possibility for Column[1], use Property 1, we have Column[2]==Column[1] || Column[2]==^Column[1], choose the better choice, then do the same with Column[3], Column[4].
Thank you so much. I now understand how to approach it. What a wonderful problem.