zoukankan      html  css  js  c++  java
  • A. Ivan the Fool and the Probability Theory

    https://codeforces.com/contest/1239/problem/A

    discription

    given a (n*m) field in which every grid can be painted black and white. count the number of different situation, where every grid has at most one adjacent grid that shares the same color.

    breakthrough

    no idea. hard limitation causes headache.

    but it turns out that we should utilize the harsh contraint wisely.
    classial and direct solutions are excluded due to scope of (n,m). and once you take up looking for a pattern you will succeed

    then you will find that if you have controlled the first row you will have controlled the whole universe unless what you have in the first row is:

    • something like WBWBWBWBWBW... then the next row is either WBWBWBWBW...(totally similar) or BWBWBWBWB..(total opposite). the third row presents the same pattern but with some limitations on columns and so does the followings. so in this situations the number of ways of where the first row altermates depends on the number of ways of all situation of the first column

    apart from that, the partial answer is the number of ways of all situation of the first row except the situation mentioned above.

    add them up and you will get the answer

  • 相关阅读:
    query compiler
    non-deterministic-turing-machine
    What-are-P-NP-NP-complete-and-NP-hard
    查询优化器的算法
    Redis 和 I/O 多路复用
    Linux aio
    MySQL 的那些网络超时错误
    MYSQL performance
    jvmti
    JVM Troubleshooting
  • 原文地址:https://www.cnblogs.com/reshuffle/p/12543085.html
Copyright © 2011-2022 走看看