思维题+set URAL 1718 Rejudge

本文深入探讨了一道关于代码优化与容器使用问题的URAL1718 Rejudge实例。通过分析代码逻辑与错误定位,展示了如何正确使用set容器解决排序问题,避免了WA情况的发生。文章详细阐述了解题思路、代码实现及运行结果,为读者提供了实际操作的指导。

 

题目传送门

 1 /*
 2     题意:数据加10组,再删掉第6组数据,问rejudge后最少最多几个作者收到邮件
 3     思维题:当错在6时结果是不一定,错在7时是一定改变,因为会变成6
 4     思路没错,但用结构题排序一直WA,代码有毒!学习使用set容器。
 5 */
 6 #include <cstdio>
 7 #include <algorithm>
 8 #include <cstring>
 9 #include <cmath>
10 #include <string>
11 #include <iostream>
12 #include <set>
13 using namespace std;
14 
15 const int MAXN = 1e3 + 10;
16 const int INF = 0x3f3f3f3f;
17 string name, res;
18 set<string> mn, mx;
19 
20 int main(void)        //URAL 1718 Rejudge
21 {
22 //    freopen ("H.in", "r", stdin);
23 
24     int n;    scanf ("%d", &n);
25     for (int i=1; i<=n; ++i)
26     {
27         cin >> name >> res;
28         if (res == "CE")    continue;
29         else if (res == "AC")
30         {
31             mx.insert (name);    continue;
32         }
33         else
34         {
35             int x;    scanf ("%d", &x);
36             if (x == 6)    mx.insert (name);
37             else if (x == 7)
38             {
39                 mn.insert (name);    mx.insert (name);
40             }
41         }
42     }
43 
44     printf ("%d %d\n", mn.size (), mx.size ());
45 
46     return 0;
47 }

 

转载于:https://www.cnblogs.com/Running-Time/p/4649534.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值