Personal programming language Gym
来源:互联网 发布:社交软件英文怎么说 编辑:程序博客网 时间:2024/06/07 02:56
d f s ,要存一下在输出
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <cmath>#include <set>#include <map>#include <stack>#include <queue>#include <ctype.h>#include <vector>#include <algorithm>#include <sstream>// cout << " === " << endl;using namespace std;typedef long long ll;const int maxn = 10000 + 7;int n;map<string, vector<string> > mp;map<string, string> ans;stack<string> ans_;map<string, int> vis;void init() { string str, s, s1; for(int i = 0; i < n; ++i) { getline(cin, str); stringstream ss(str); while(ss >> s) { if(s == "def") { ss >> s1; } else if(s == "with") { ss >> s; mp[s1].push_back(s); } else if(s == "=") { ss >> s; ans[s1] = s; } } }}void dfs(string s) { if(mp[s].size() == 0) { if(vis[s] == 0) { ans_.push(ans[s]); vis[s]++; } return; } for(int i = mp[s].size()-1; i >= 0; --i) { if(!vis[mp[s][i]])dfs(mp[s][i]); } if(vis[s] == 0) { ans_.push(ans[s]); vis[s]++; } return;}int main() { ios::sync_with_stdio(false); cin >> n; cin.get(); init(); string s; cin >> s; dfs(s); string t = ans_.top(); ans_.pop(); cout << t; while(!ans_.empty()) { t = ans_.top(); ans_.pop(); cout << " " << t; } return 0;}
阅读全文
1 0
- Personal programming language Gym
- Personal programming language Gym
- Programming Language
- The Curl Programming Language
- The Curl Programming Language
- The Programming Language Tips
- Perl Programming Language
- The Programming Language Idioms
- The Curl Programming Language
- Language Oriented Programming
- The D Programming Language
- Language Oriented Programming (翻译)
- D Programming Language
- Language Oriented Programming
- Ruby Programming language
- The C++ Programming Language
- Ruby Programming Language:
- Programming | Language | C
- 228215004284
- 2017 Multi-University Training Contest
- Python 3.0 基础知识
- VMware vSphere Web Services SDK编程指南(八)- 8.3 从 UserDirectory 获取用户和组信息
- 树莓派搭WEB控制点灯(微信点灯,网页控制电机等)
- Personal programming language Gym
- composer使用
- 有序01字符串
- 2017.8.22区间最大值问题
- java学习笔记(一)--泛型与反射学习
- python 数组保存到json 文件
- Atmel——目录
- Java的数据类型与运算符
- [px4仿真]px4的STIL仿真中添加向下的摄像头