【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

用map+set写个模拟就好。
3个区域
书架、桌子、别人的手上。
其中前两个区域的书都能借出去。

【代码】

#include <bits/stdc++.h>
using namespace std; set <pair<string, string> > mset1,mset2,mset3;
map<string, string> author;
string s1,s2,s3; int main()
{
//freopen("F:\\rush.txt", "r", stdin);
while (getline(cin,s1))
{
if(s1 == "END") break;
s2 = "";
int now = 1;
while (s1[now] != '"') s2 += s1[now++];
assert(s1[now] == '"');
now+=5;
s3 = s1.substr(now);
mset1.insert(make_pair(s3, s2));
author[s2] = s3;
}
while (getline(cin, s1))
{
if (s1 == "END") break;
if (s1[0] == 'B')
{
s2 = s1.substr(8);
s2.erase((int)s2.size() - 1);
auto it = mset1.find(make_pair(author[s2], s2));
if (it != mset1.end())
{
mset3.insert((*it));
mset1.erase(it);
}
else {
it = mset2.find(make_pair(author[s2], s2));
if (it != mset2.end())
{
mset3.insert((*it));
mset2.erase(it);
}
}
}
else
if (s1[0] == 'R')
{
s2 = s1.substr(8);
s2.erase((int)s2.size() - 1);
auto it = mset3.find(make_pair(author[s2], s2));
if (it != mset3.end())
{
mset2.insert((*it));
mset3.erase(it);
}
}
else {
for (auto temp : mset2)
{
mset1.insert(temp);
auto it = mset1.find(temp);
if (it != mset1.begin())
{
it--;
cout << "Put " << '"' << temp.second << '"' << " after " << '"' << (*it).second << '"' << endl;
}
else
cout << "Put "<<'"'<<temp.second << '"'<<" first" << endl;
}
cout << "END" << endl;
mset2.clear();
} }
return 0;
}

【习题 5-8 UVA - 230】Borrowers的更多相关文章

  1. uva 230 Borrowers(摘)<vector>"结构体“ 膜拜!

    I mean your borrowers of books--those mutilators of collections, spoilers of the symmetry of shelves ...

  2. UVa 230 Borrowers(map和set)

    I mean your borrowers of books - those mutilators of collections, spoilers of the symmetry of shelve ...

  3. Uva - 230 - Borrowers

    AC代码: #include <iostream> #include <cstdio> #include <cstdlib> #include <cctype ...

  4. UVA 230 Borrowers (STL 行读入的处理 重载小于号)

    题意: 输入若干书籍和作者名字,然后先按作者名字升序排列,再按标题升序排列,然后会有3种指令,BORROW,RETURN, SHELVE. BORROW 和 RETURN 都会带有一个书名在后面,如: ...

  5. Borrowers UVA - 230

      I mean your borrowers of books - those mutilators of collections, spoilers of the symmetry of shel ...

  6. ACM训练计划建议(写给本校acmer,欢迎围观和指正)

    ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...

  7. ACM训练计划建议(转)

    ACM训练计划建议 From:freecode#  Date:2015/5/20 前言: 老师要我们整理一份训练计划给下一届的学弟学妹们,整理出来了,费了不少笔墨,就也将它放到博客园上供大家参考. 菜 ...

  8. 动态规划 Dynamic Programming 学习笔记

    文章以 CC-BY-SA 方式共享,此说明高于本站内其他说明. 本文尚未完工,但内容足够丰富,故提前发布. 内容包含大量 \(\LaTeX\) 公式,渲染可能需要一些时间,请耐心等待渲染(约 5s). ...

  9. UVa第五章STL应用 习题((解题报告))具体!

    例题5--9 数据库 Database UVa 1592 #include<iostream> #include<stdio.h> #include<string.h&g ...

随机推荐

  1. LA 2531 The K-league 最大流

    #include <iostream> #include <cstdio> #include <fstream> #include <algorithm> ...

  2. poj 2480 Longge&#39;s problem 积性函数性质+欧拉函数

    题意: 求f(n)=∑gcd(i, N) 1<=i <=N. 分析: f(n)是积性的数论上有证明(f(n)=sigma{1<=i<=N} gcd(i,N) = sigma{d ...

  3. Atcoder At Beginner Contest 068 C - Cat Snuke and a Voyage

    C - Cat Snuke and a Voyage Time limit : 2sec / Memory limit : 256MB Score : 300 points Problem State ...

  4. TypeScript基础知识

    一. TypeScript是js的超集,可以应用所有js语法 二. 特点: 1. 优点 a. 可以在编译阶段就发现大部分错误,这总比在运行时候出错好 b. 同一目录下不同文件中,使用统一命名,会有命名 ...

  5. 1.字符设备驱动------Linux中断处理体系结构

    一.中断处理体系结构的初始化 Linux内核将所有的中断统一编号,使用一个irq_desc结构数组来描述这些中断;每个数组项对应一个中断,也可能是一组中断,它们共用相同的中断号,里面记录了中断的名称. ...

  6. Dialog和FormView如何派生通用类

    派生通用类涉及到派生类的构造函数需要传递窗口ID和CWnd,所以要在派生类中事先定义好 在Dialog中构造函数是这样定义的 public: CDialogEx(); CDialogEx(UINT n ...

  7. 【2017中国大学生程序设计竞赛 - 网络选拔赛】A Secret

    [链接]http://acm.hdu.edu.cn/showproblem.php?pid=6153 [题意] ,S2中出现的次数与其长度的乘积之和.  [题解] 扩展KMP的模板题. 首先,把S2和 ...

  8. CMake编译Makefile

    以编译Libtif文件为例: 你可以用CMake编译libtiff,超简单,两个步骤. 参考文章 CharlesSimonyi,libtiff库的问题的答复

  9. dot-files/directories 点开头的文件或文件夹(windows/linux)

    What's so special about directories whose names begin with a dot? 不管是 windows 系统,还是类 linux 系统,以点开头的文 ...

  10. C# foreach 循环遍历数组

    using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace Cons ...