absi2011's Blog & Daily Life.

全新的开始       我要省选翻盘       I wanna AK in 高考\化学       自此,生无可恋
[搬家]Codeforces 576B
POJ 3910 解题报告

100506 I 解题报告

absi2011 posted @ 9 年前 in 刷题记录 with tags 模拟 CF Gym , 427 阅读

最近我在写非人类题目啊...

链接:http://codeforces.com/gym/100506/attachments/download/2760/20142015-ct-s02e06-codeforces-trainings-season-2-episode-6-en.pdf

题意:

给出若干个ACM队的成绩,求排名

特殊规则:

如果罚时都相同,那么考虑最大的X,使得两者可以得分情况不同(做出题目数或者罚时不同)

如果再相同那只好相同了...

解法:没啥好说的,暴力去

代码:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
#include<set>
#include<map>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<time.h>
#include<math.h>
#include<memory>
#include<vector>
#include<bitset>
#include<fstream>
#include<stdio.h>
#include<utility>
#include<sstream>
#include<string.h>
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;
struct team
{
    string name;
    int ac[15];
    int unac[15];
    int ac_problems;
    int sum_time;
    friend bool operator < (const team &a,const team &b)
    {
        if (a.ac_problems!=b.ac_problems)
        {
            return a.ac_problems>b.ac_problems;
        }
        else if (a.sum_time!=b.sum_time)
        {
            return a.sum_time<b.sum_time;
        }
        else
        {
            int i;
            int aa=9,bb=9;
            int unsolved_a=0;
            int unsolved_b=0;
            int unget_time_a=0;
            int unget_time_b=0;
            for (i=300;i>=1;i--)
            {
                for (;aa>=0;)
                {
                    if (a.ac[aa]>i)
                    {
                        unsolved_a++;
                        unget_time_a+=a.ac[aa];
                        unget_time_a-=a.unac[aa]*20;
                        aa--;
                    }
                    else
                    {
                        break;
                    }
                }
                for (;bb>=0;)
                {
                    if (b.ac[bb]>i)
                    {
                        unsolved_b++;
                        unget_time_b+=b.ac[bb];
                        unget_time_b-=b.unac[bb]*20;
                        bb--;
                    }
                    else
                    {
                        break;
                    }
                }
                if (unsolved_a!=unsolved_b)
                {
                    return unsolved_a<unsolved_b;
                }
                else if (unget_time_a!=unget_time_b)
                {
                    return unget_time_a>unget_time_b;
                }
            }
        }
        return a.name<b.name;
    }
    friend bool operator > (const team &a,const team &b)
    {
        if (a.ac_problems!=b.ac_problems)
        {
            return a.ac_problems<b.ac_problems;
        }
        else if (a.sum_time!=b.sum_time)
        {
            return a.sum_time>b.sum_time;
        }
        else
        {
            int i;
            int aa=9,bb=9;
            int unsolved_a=0;
            int unsolved_b=0;
            int unget_time_a=0;
            int unget_time_b=0;
            for (i=300;i>=1;i--)
            {
                for (;aa>=0;)
                {
                    if (a.ac[aa]>i)
                    {
                        unsolved_a++;
                        unget_time_a+=a.ac[aa];
                        unget_time_a-=a.unac[aa]*20;
                        aa--;
                    }
                    else
                    {
                        break;
                    }
                }
                for (;bb>=0;)
                {
                    if (b.ac[bb]>i)
                    {
                        unsolved_b++;
                        unget_time_b+=b.ac[bb];
                        unget_time_b-=b.unac[bb]*20;
                        bb--;
                    }
                    else
                    {
                        break;
                    }
                }
                if (unsolved_a!=unsolved_b)
                {
                    return unsolved_a>unsolved_b;
                }
                else if (unget_time_a!=unget_time_b)
                {
                    return unget_time_a<unget_time_b;
                }
            }
        }
        return false;
    }
    void clear()
    {
        memset(ac,0,sizeof(ac));
        memset(unac,0,sizeof(unac));
        ac_problems=0;
        name="";
        sum_time=0;
    }
    void calc()
    {
        int i,j;
        for (i=0;i<10;i++)
        {
            for (j=i;j<10;j++)
            {
                if (ac[i]>ac[j])
                {
                    swap(ac[i],ac[j]);
                    swap(unac[i],unac[j]);
                }
            }
        }
    }
};
team a[105];
map<string,int> ma;
int main()
{
    #ifdef absi2011
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    int t;
    cin>>t;
    int zu;
    for (zu=0;zu<t;zu++)
    {
        ma.clear();
        int n,m;
        cin>>n>>m;
        int i;
        for (i=0;i<n;i++)
        {
            a[i].clear();
            cin>>a[i].name;
            ma[a[i].name]=i;
        }
        for (i=0;i<m;i++)
        {
            int time;
            string name;
            cin>>time;
            cin>>name;
            char prob;
            cin>>prob;
            string state;
            cin>>state;
            if (state=="rejected")
            {
                if (a[ma[name]].ac[prob-'A']>=1) continue;
                a[ma[name]].unac[prob-'A']--;
            }
            else
            {
                if (a[ma[name]].ac[prob-'A']>=1) continue;
                a[ma[name]].sum_time-=20*a[ma[name]].unac[prob-'A'];
                a[ma[name]].sum_time+=time;
                a[ma[name]].ac[prob-'A']=time;
                a[ma[name]].ac_problems++;
            }
        }
        for (i=0;i<n;i++)
        {
            a[i].calc();
        }
        sort(a,a+n);
        int rank=1;
        for (i=0;i<n;i++)
        {
            if ((i==0)||(a[i]>a[i-1]))
            {
                rank=i+1;
            }
            printf("%d %s %d %d\n",rank,a[i].name.c_str(),a[i].ac_problems,a[i].sum_time);
        }
    }
    return 0;
}

登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter