20240509

「忍者と極道」が面白すぎて生活リズムが崩れた。I wonder if I can wake up early for tomorrow’s Codeforces contest.


1972B. Coin Games

Editorial

I misunderstood the problem. I thought “flips the two coins that are adjacent to it” means

FRF, R => coin to remove, F => coins to flip

but as the sapmle input shows, this is also possible

RFF, FFR

and the approach is to count the number of U for each stage. It turns out that the parity of the coins switch for each operation.

package main

import (
    "fmt"
)

func main() {
    var t int
    fmt.Scan(&t)

    for tc := 0; tc < t; tc++ {
        var n int
        fmt.Scan(&n)

        var s string
        fmt.Scan(&s)
        parity := 0
        for i := 0; i < n; i++ {
            if s[i] == 'U' {
                parity += 1
                parity %= 2
            }
        }
        if parity == 0 {
            fmt.Println("NO")
        } else {
            fmt.Println("YES")
        }
    }
}

TODO: Review this problem again.


Avocado rolls 300 Sushi bowl 600 Chips 500 Kombucha 200

Total 1600 kcal


index 20240508 20240510