P2161-[SHOI2009]会场预约


 1 #include <bits/stdc++.h>
 2 typedef long long ll;
 3 using namespace std;
 4 #define _for(i,a,b) for(int i = (a);i < b;i ++)
 5 #define _rep(i,a,b) for(int i = (a);i > b;i --)
 6 #define INF 0x3f3f3f3f
 7 #define MOD 1000000007
 8 #define pb push_back
 9 #define maxn 100003
10 inline ll read()
11 {
12     ll ans = 0;
13     char ch = getchar(), last = ' ';
14     while(!isdigit(ch)) last = ch, ch = getchar();
15     while(isdigit(ch)) ans = (ans << 1) + (ans << 3) + ch - '0', ch = getchar();
16     if(last == '-') ans = -ans;
17     return ans;
18 }
19 inline void write(ll x)
20 {
21     if(x < 0) x = -x, putchar('-');
22     if(x >= 10) write(x / 10);
23     putchar(x % 10 + '0');
24 }
25 struct P
26 {
27     int l;
28     int r;
29     bool operator <(const P &x) const
30     {
31         return r<x.l;
32     }
33 };
34 int N;
35 set<P> s;
36 int main()
37 {
38     N = read();
39     while(N--)
40     {
41         string op;
42         cin >> op;
43         if(op=="A")
44         {
45             P tp;
46             tp.l = read();
47             tp.r = read();
48             int ans = 0;
49             auto it = s.find(tp);
50             while(it != s.end())
51             {
52                 ans ++;
53                 s.erase(it);
54                 it = s.find(tp);
55             }
56             s.insert(tp);
57             write(ans);
58             printf("\n");
59         }
60         else
61         {
62             write(s.size());
63             printf("\n");
64         }
65     }
66     return 0;
67 }

优质内容筛选与推荐>>
1、PAT A1002 A+B for Polynomials(25)
2、CVE-2015-8660分析
3、PAT A1003 Emergency(25)
4、百度分享
5、table实现 js数据访问 传递json数据用render_to_response


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号