CF20A.BerOS file system

普及+/提高

通过率:0%

时间限制:2.00s

内存限制:64MB

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

The new operating system BerOS has a nice feature. It is possible to use any number of characters '/' as a delimiter in path instead of one traditional '/'. For example, strings //usr///local//nginx/sbin// and /usr/local/nginx///sbin are equivalent. The character '/' (or some sequence of such characters) at the end of the path is required only in case of the path to the root directory, which can be represented as single character '/'.

A path called normalized if it contains the smallest possible number of characters '/'.

Your task is to transform a given path to the normalized form.

新型操作系统 BerOS 具有一个很棒的特性:在路径中可以使用任意数量的字符 / 作为分隔符,而不仅限于传统的单个 /。例如,字符串 //usr///local//nginx/sbin// 和 /usr/local/nginx///sbin 是等价的。路径末尾的字符 /(或一串这样的字符)仅在表示根目录时是必需的;根目录可表示为单个字符 /。

若一个路径所含的字符 / 的数量达到最小,则称该路径为规范化路径(normalized)。

你的任务是将给定路径转换为规范化形式。

输入格式

The first line of the input contains only lowercase Latin letters and character '/' — the path to some directory. All paths start with at least one character '/'. The length of the given line is no more than 100 characters, it is not empty.

输入的第一行仅包含小写拉丁字母和字符 /,表示某个目录的路径。所有路径均以至少一个字符 / 开头。给定行的长度不超过 100 个字符,且非空。

输出格式

The path in normalized form.

归一化形式的路径。

输入输出样例

  • 输入#1

    //usr///local//nginx/sbin

    输出#1

    /usr/local/nginx/sbin

输入解题思路,AI测评打分。不知道怎么写?

首页