← CSES Better

Censoring (Silver)

USACO · 2015 · February · silver-1

Open official problem ↗
Ask AI

Open a hint-first prompt in a new AI chat. Grok may ask you to confirm before sending.

Open Claude Desktop

strings · suffix-deletion

The organizer’s problem statement is available at the official source link.

sample trace

Censoring: remove matching suffixes

Build the result from left to right. Whenever its newest suffix equals the censored word, remove that suffix immediately.

input

whatthemomooofun

pattern

moo

stack Result

whatthefun

events

append characters left to rightsuffix moo appears; remove itcontinue with remaining characters

edges

  • from
    input
    to
    stackResult
    label
    append / remove matching suffix
  1. 1

    Append

    Read the input one character at a time into the output stack.
  2. 2

    Check the suffix

    After each append, test whether the stack now ends in the pattern moo.
  3. 3

    Delete and continue

    Remove the matching suffix; the sample finishes as whatthefun.
Tools
1
2
3
4
5
6
7
8
9
10
11
12
Draft saved locally
|12 lines, 156 chars

Run output

Run your code to see output.