UVA 230(p136)----Borrowers
来源:互联网 发布:企业管理优化建议 编辑:程序博客网 时间:2024/05/21 19:43
#include<map>#include<cstdio>#include<vector>#include<iostream>#include<algorithm>#define debuusing namespace std;struct point{ string bk,wr;};vector<point> lt;map<string,int> name;int cmp(point a,point b){ if(a.wr==b.wr) return a.bk<b.bk; else return a.wr<b.wr;}int Find(int p){ for(int i=p; i>=0; i--) if(name[lt[i].bk]==2) return i; return -1;}int main(){#ifdef debug freopen("in.in","r",stdin); // freopen("out.out","w",stdout);#endif // debug string st; while(getline(cin,st)) { if(st=="END") break; int l=st.length(); int p1=st.find_last_of('"'); int p2=st.find_last_of('"'); point u; u.bk=st.substr(0,p1+1); u.wr=st.substr(p2+1); lt.push_back(u); } sort(lt.begin(),lt.end(),cmp); for(int i=0; i<lt.size(); i++) name[lt[i].bk]=2; while(getline(cin,st)) { if(st=="END") break; if(st[0]!='S') { int i,flag=0; int p1=st.find_first_of('"'); int l=st.length(); string tmp; tmp=st.substr(p1); if(st[0]=='B') name[tmp]=-1; else name[tmp]=1; } else { for(int i=0; i<lt.size(); i++) { if(name[lt[i].bk]==1) { int p=Find(i); if(p!=-1) cout<<"Put "<<lt[i].bk<<" after "<<lt[p].bk<<endl; else cout<<"Put "<<lt[i].bk<<" first"<<endl; name[lt[i].bk]=2; } } cout<<"END"<<endl; } } return 0;}题目地址:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=4&page=show_problem&problem=166
0 0
- UVA 230(p136)----Borrowers
- UVA - 230 Borrowers
- UVa 230 - Borrowers
- UVA - 230 Borrowers
- UVA-230 Borrowers
- Uva - 230 - Borrowers
- UVA 230 Borrowers
- UVa 230 Borrowers
- uva 230 Borrowers
- UVA 230 Borrowers
- uva 230 Borrowers
- UVa 230 Borrowers
- UVa 230 - Borrowers(模拟)
- UVA - 230 Borrowers string+vector
- UVA 230 Borrowers (STL运用)
- UVA 230 Borrowers 简单模拟
- 【UVA】230 - Borrowers(map模拟)
- UVA 230 Borrowers(图书管理系统)
- UVA 225(p214)----Golygons
- 关于iOS多线程
- My架构师之路
- CSS水平/垂直居中方法一览
- js基础
- UVA 230(p136)----Borrowers
- OPENCV之人眼检测
- Linux精讲——cp命令
- 喊啥--主页面代码
- Spring Aop 表达式匹配
- UVA 247(p365)----Calling Circles
- leetcode随笔II
- Objective-C Runtime
- Java游戏服务端编程心得