wsaleem's blog

By wsaleem, 2 hours ago, In English

580948A - Tricky Template

We only need to check $$$a_i, b_i, c_i$$$ for each $$$1\le i\le n$$$. We guess $$$t_i$$$ based on $$$a_i$$$ and $$$b_i$$$. If, for any $$$i$$$, there is a mismatch between $$$c_i$$$ and $$$t_i$$$, the output is YES, otherwise, it is NO.

There are 2 cases, each with its subcases.

  • $$$a_i \ne b_i$$$
    • $$$t_i$$$ must be $$$X$$$ where $$$x \ne a_i$$$ and $$$x \ne b_i$$$. To mismatch, $$$c_i$$$ must be $$$x$$$, i.e. $$$c_i !\ne a_i$$$ and $$$c_i \ne b_i$$$
  • $$$a_i = b_i$$$
    • $$$t_i$$$ may be $$$X$$$ where $$$x \ne a_i$$$ and $$$x \ne b_i$$$. To mismatch, $$$c_i$$$ must be $$$x$$$, i.e. $$$c_i !\ne a_i$$$ and $$$c_i \ne b_i$$$
    • $$$t_i$$$ may be uppercase $$$A_i$$$ (note, $$$a_i=b_i$$$ in this case). To mismatch, $$$c_i$$$ must be different from lowercase $$$a_i$$$, i.e. $$$c_i !\ne a_i$$$ and $$$c_i \ne b_i$$$.

In all cases, for $$$c_i$$$ to mismatch, it must be that $$$c_i !\ne a_i$$$ and $$$c_i \ne b_i$$$.

Original problem: 1922A - Tricky Template, leads to official tutorial and all solutions including WS solution: 300910838

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By wsaleem, 11 hours ago, In English

579968A - Different String

Check the number of unique characters in the string. If this is $$$1$$$, the string cannot be rearranged, otherwise perform any transformation that guarantees a different string, e.g. a cyclic right shift.

Original problem: 1971B - Different String, leads to official tutorial and all solutions including WS solution: 300389137

579968B - Young Physicist

Check if every column sums to $$$0$$$.

Original problem: 69A - Young Physicist, leads to official tutorial and all solutions including WS solution: 254038247

579968C - New Year Transportation

The user makes moves. The user is at index $$$i$$$ at the start of a move and at index $$$i+a_i$$$ at its end, which becomes the starting index for the next move. The user moves until the index exceeds $$$t-1$$$. If the index is now $$$t-1$$$ then the user has arrived, otherwise not.

Original problem: 500A - New Year Transportation, leads to official tutorial and all solutions including WS solution: 300594655

579968D - Polycarp's Practice

One solution is to identify the indexes, $$$i_1, i_2,\ldots,i_k$$$, and values of the $$$k$$$ largest values in $$$a$$$. The total profit is the sum of the values. $$$t_1=i_1$$$ (assuming 1-based indexing), $$$t_2=i_2-i_1, t_3=i_3-i_2$$$, and so on. Take care with the last index, $$$t_k$$$. If $$$i_k$$$ is not $$$n$$$, then $$$t_k$$$ will not include the elements $$$a_{i_k+1}, a_{i_k+2}, \ldots,a_{n}$$$. This can be fixed by setting $$$i_k=n$$$.

Original problem: 1006B - Polycarp's Practice, leads to official tutorial and all solutions including WS solution: 300648369

Full text and comments »

  • Vote: I like it
  • 0
  • Vote: I do not like it

By wsaleem, history, 5 months ago, In English

I learn a lot by looking at other people's solutions. It will be great if I can show my appreciation of some solution, e.g., by starring it. We can already upvote comments and blog entries, and star users. Something like that will be nice for solutions. It will also serve as encouragement to users who write good solutions.

Full text and comments »

  • Vote: I like it
  • +17
  • Vote: I do not like it