AlgoLensArena
ContestlərProblemlərOtaqlar
Vizualizator
← Məsələlər

FPC21-025.Icarus' Rebirth

Easy · 1 s · 256 MB

  • icpc
  • fpc
  • 2021

In an attempt to escape from Crete's highest tower, where they were imprisoned, Icarus and his father Daedalus made two pairs of wings, with which they could fly away to Athens. During their flight, all was well until Icarus' hubris led him to fly too close to the sun, causing his wings to melt and him to drown in the Mediterranean Sea. Mourning the loss of his child, Daedalus now undertakes a perilous journey through the underworld to find Hades – the god of the dead. He meets Hades and begs him to give back his son.

“Your request shall be granted, craftsman, but only if you prove yourself worthy by solving this task,” says Hades. “I shall give you a word in the language of the gods. You see, the way we gods measure a word's length is different from the method you humans use. We measure the length of a word by calculating the minimum number of steps that need to be taken from the first character, to reach the last one. In a step, starting from the character with value xxx at position iii, you may either go to a character with position i−1i-1i−1 or i+1i+1i+1, or you can go to the closest character with value xxx to the left or to the right.” Daedalus is a smart man, and knowing he can not solve this problem for enormous words, he asks you to write a computer program that calculates the length of any word on your magical stone tablet.

Given some word in the language of the gods, calculate its length according to the gods' way of measuring, so Daedalus can take back his beloved son Icarus.

Giriş formatı

The input consists of:

• A line with a single word www (1≤∣w∣≤1051\leq |w|\leq 10^51≤∣w∣≤105). The word contains only lowercase letters from the English alphabet (‘a-z’).

Çıxış formatı

Output a single number, the length of the word www, according to the gods' way of measuring.

Qeyd

Source: Freshmen Programming Contest 2021 · Author: Cristian - Alexandru Botocan · License: CC BY-SA 4.0 · Original: https://fpc.wisv.ch · Statement adapted for AlgoLens and shared under the same license.

Nümunələr

Giriş #1

word

Çıxış #1

3

Giriş #2

adiacrac

Çıxış #2

3