zoukankan      html  css  js  c++  java
  • UVa-230

    终于在UVa上AC了50题了,感觉还有很长的路要走!!!

    这道题有点麻烦,还是用STL写的。

     1 #include<iostream>
     2 #include<cstdio>
     3 #include<cstring>
     4 #include<set>
     5 #include<map>
     6 using namespace std;
     7 const int maxx=1010;
     8 typedef struct Node
     9 {
    10     string book,name;
    11     bool operator<(const struct Node &x)const
    12     {
    13         if(name!=x.name) return name<x.name;
    14         return book<x.book;
    15     }
    16 }node;
    17 int main()
    18 {
    19     //freopen("in.txt","r",stdin);
    20     //freopen("out.txt","w",stdout);
    21     set<node> st;
    22     map<string,string> mp;
    23     string s;
    24     node tnode;
    25     int p;
    26     while(getline(cin,s))
    27     {
    28         if(s[0]=='E') break;
    29         p=s.find('"',1);
    30         tnode.book=s.substr(0,p+1);
    31         tnode.name=s.substr(p+5);
    32         mp.insert(make_pair(tnode.book,tnode.name));
    33         st.insert(tnode);
    34     }
    35     set<node> st1;
    36     while(getline(cin,s))
    37     {
    38         if(s[0]=='E') break;
    39         if(s[0]=='S')
    40         {
    41             set<node>::iterator it,it1;
    42             for(it=st1.begin();it!=st1.end();it++)
    43             {
    44                 cout<<"Put "<<it->book<<" ";
    45                 it1=st.lower_bound(*it);
    46                 if(st.empty()||it==st.begin()) cout<<"first"<<endl;
    47                 else cout<<"after "<<(--it1)->book<<endl;
    48                 st.insert(*it);
    49             }
    50             st1.clear();
    51             cout<<"END"<<endl;
    52         }
    53         else
    54         {
    55             p=s.find('"');
    56             string book=s.substr(p);
    57             tnode.book=book;
    58             tnode.name=mp[book];
    59             if(s[0]=='B') st.erase(tnode);
    60             else st1.insert(tnode);
    61         }
    62     }
    63 }
  • 相关阅读:
    mysql大数据的分表
    php settype()和gettype()
    php的类型转换
    php 时间戳和时间的转换
    mysql的数据类型
    thinkphp vender
    (function(){})();和(function(){}())每个括号的用途和区别
    数字的空洞 水 南邮NOJ 1071
    111... 南邮NOJ 1079
    阿里在线笔试题 折半方法求最接近sum值
  • 原文地址:https://www.cnblogs.com/windrises/p/4655736.html
Copyright © 2011-2022 走看看