TJU训练赛—D
来源:互联网 发布:化学反应软件 编辑:程序博客网 时间:2024/04/30 04:17
Time Limit: 1.0 Seconds Memory Limit: 65536K
Total Runs: 393 Accepted Runs: 134
God Le is the most talented ACMer in the TJU-ACM team.
When he wants to open a file,he can just use his keyboard instead of using his mouse to click.
Why he can do this?Because he uses the cmd.exe. There are many commands in cmd.exe.But God Le is kind of lazy,so he just uses three commands to change the current directory.
"cd dir"(without quotes):put you in a subdirectory.For example,if you are in C:\Programs,typing cd Vim will put you in C:\Programs\Vim.
"Disk(like C,D,etc):"(without quotes):put you in the directory in that Disk that you are in most recently.For example,if you are in C:\Programs,typing D: and C: will put you in C:\Programs.(at the beginning,when you type Disk:,you will be in Disk:\).
"cd .."(without quotes):move you up one directory.So,if you are in C:\Programs\Vim,cd .. moves you to C:\Programs.
Because God Le is very smart,he won't go to the directory that is not existed. Now,given a sequence of commands,God Le wants to know the current directory.
One thing that you should know is that God Le's computer only have four disks C,D,E,F.
HINT I:The initial directory is C:\users\godle
HINT II:every subdirectory is only a string contains no more than 10 lower-case letters.
Input
There are mulit cases.Each case begins with an integer m(1 ≤ m ≤ 10^3)means the operations.Next there are m lines.Each line contains a command.
Output
For each command,print the current directory.You can get more hints from the sample.
Sample Input
5cd ..D:cd ..cd abcC:
Sample Output
C:\usersD:D:D:\abcC:\users
注意一下如果当前在 C:\111
进行
D:
C:
操作回到C:\111而不是C:\。
另外注意反斜杠是'\\'
#include <iostream>#include <cstring>#include <cstdio>#include <cmath>#include <algorithm>using namespace std;int main() { string ans[5],s,t; int n;while(~scanf("%d",&n)) { int now=0;ans[0]= "C:\\users\\godle";ans[1]= "D:";ans[2]= "E:";ans[3]= "F:";for(int i=0;i<n;i++) { cin>>s;if(s=="cd") { cin>>t; if(t=="..") { int j; for(j=ans[now].length()-1;j>=0;j--) if(ans[now][j]=='\\') break; if(j>=0) ans[now].erase(j,ans[now].length()-j); } else ans[now]+="\\"+t; } if(s=="C:") now=0; if(s=="D:") now=1; if(s=="E:") now=2; if(s=="F:") now=3;cout<<ans[now]<<endl; } } return 0; }
- TJU训练赛—D
- TJU训练赛—A
- TJU训练赛—B
- TJU训练赛—C
- TJU训练赛—E
- TJU训练赛—G
- TJU训练赛—L
- TJU训练赛—J
- TJU 3007 D Decoding(精简版)
- BNU训练赛 D 交集
- zzuli训练赛_05_13-D
- tju 4072. 3D Birds-Shooting Game(k-d树)
- 【KD tree】 TJU 4072 3D Birds-Shooting Game
- 暑期训练赛(6)D
- 2015寒假训练赛一-D题
- 暑假集训——个人训练赛04——D题
- 第一场个人训练赛——D-求绝对值(HDU 2003)
- 数论专题训练D
- 合并两个有序链表
- SQL For Test
- 合并两个有序的单链表
- iOS积累-iOS图片填充UIImageView(contentMode)
- UI测试常见bug
- TJU训练赛—D
- java 下的 AES org.bouncycastle.crypto 包加密解密算法示例
- Opencv在Release和Debug不同模式下的配置
- Java class 文件信息
- spark on yarn cluster 与 client 模式的区别
- HTML小结及css基础属性
- 未来币nxt 启动分析(1)
- 轮播图的实现原理
- Mysql 忘记root密码的解决方法