Codeforces Round 920 (Div. 3)

基本情况

A、C秒的很快。B、D都错了一发才过。E博弈论属于是短板。

E. Eat the Chip

Problem - E - Codeforces

首先考虑谁可能赢。

因为 \(Alice\) 只能向下, \(Bob\) 只能向上,而 \(Alice\) 先手。

显然两者行差为奇数时 \(Alice\) 有可能赢,偶数时 \(Bob\) 有可能赢。

再考虑平局情况

\(Alice\) 赢的情况考虑:

  • \(Alice\) 的步数是游戏轮数加一。
  • 两人列数差距小于等于一时,\(Alice\) 能赢
  • 两人列数大于一时
    • \(Bob\) 肯定往远离 \(Alice\) 的地方走。
      • \(Alice\) 只要能够碰壁,即和墙壁的距离小于等于步数,仍然能吃 \(Bob\)
      • 否则平局。
void solve()
{
    int n, m, x1, y1, x2, y2;
    cin >> n >> m >> x1 >> y1 >> x2 >> y2;
    if (x1 >= x2) {
        cout << "Draw" << endl;
        return ;
    }
    if (x2 - x1 & 1) {//Alice win
        int turn = (x2 - x1) / 2 + 1;//Alice's step
        if (abs(y1 - y2) <= 1 || y1 < y2 && m - y1 <= turn || y1 > y2 && y1 - 1 <= turn) 
            cout << "Alice" << endl;
        else 
            cout << "Draw" << endl;
    } else {//Bob win
        int turn = (x2 - x1) / 2;//Bob's step
        if (y1 == y2 || y2 < y1 && m - y2 <= turn || y2 > y1 && y2 - 1 <= turn)
            cout << "Bob" << endl;
        else 
            cout << "Draw" << endl;
    }
}
posted @ 2024-01-16 13:47  加固文明幻景  阅读(54)  评论(0编辑  收藏  举报