A. BerOS file system
来源:互联网 发布:mac 梦幻西游手游网页 编辑:程序博客网 时间:2024/06/05 11:17
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.
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.
The path in normalized form.
//usr///local//nginx/sbin
/usr/local/nginx/sbin
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<cmath>
#include<stdlib.h>
#include<iomanip>
#include<list>
#include<deque>
#include<map>
#include <stdio.h>
#include <queue>
#include <stack>
#define maxn 10000+5
#define ull unsigned long long
#define ll long long
#define reP(i,n) for(i=1;i<=n;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define cle(a) memset(a,0,sizeof(a))
#define mod 90001
#define PI 3.141592657
#define INF 1<<30
const ull inf = 1LL << 61;
const double eps=1e-5;
using namespace std;
bool cmp(int a,int b){
return a>b;
}
int main()
{
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
string s;
while(cin>>s){
stack<char>st;
for(int i=0;i<s.size();i++){
if(st.empty())
st.push(s[i]);
else
if(st.top()=='/'&&s[i]=='/'){
continue;
}
else st.push(s[i]);
}
string t="";
while(!st.empty()){
t+=st.top();
st.pop();
}
if(t.size()>1){
for(int i=t.size()-1;i>=1;i--)
cout<<t[i];
if(t[0]!='/')cout<<t[0];
}
else cout<<t[0];
cout<<endl;
}
return0;
}
- A. BerOS file system
- cf 20a BerOS file system
- Code Forces 20A BerOS file system
- CDOJ_327 BerOS file system
- CodeForces 20A BerOS file system (简单题)
- 【水I/O】#20 A. BerOS file system
- Project5: Design a File System
- Choose a journaling file system
- CIFS: A Common Internet File System
- Tips for Writing a File System Filter
- Check for a case sensitive file system
- System Navigator - A Versatile File Manager
- unable to find a medium containing a live file system
- how to unzip a file in a system directory
- file system
- file system
- File system
- A Common Internet File System (CIFS/1.0) Protocol
- Mongoose使用操作
- A. Flag
- A. Noldbach problem
- A. Triangle
- A. World Football Cup
- A. BerOS file system
- A. Jabber ID
- A. Second Order Statistics
- A. You\'re Given a String...
- A. Ring road
- A. IQ test
- A. Almost Prime
- A. Next Test
- Oracle内置表二