Last Submissions | ||||||
---|---|---|---|---|---|---|
Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
| discuss10258 - | Accepted | C++11 | 0.080 | 0.000 | 6408 | 1 mins ago |
Problem: click 10258
Suggest:
First I sort the input ascending by time so that I can calculate the number of solved, penatly problems for each team.
I continued to sort the results of each team according to the requirements of the problem and came up with the rankings.
NOTE: It took me almost 10 times WA to AC for the following reason:
1. The last test must not output a blank line
2. Note that the problem is required to only penalize the "incorrect" before the "correct". This means that at the same time the problem is submitted with both "incorrect" and "correct", "incorrect" will not be counted.
#include<bits/stdc++.h>
#define N 1000111
using namespace std;
struct input{
int team, prob, time;
string state;
};
input a[N];
bool incomp(input t, input f){
if (t.time < f.time) return true;
if (t.time == f.time)
return (t.state > f.state);
return false;
}
struct output{
int team, probs, pena= 0;
};
output b[N];
bool outcomp(output t, output f){
if (t.probs > f.probs) return true;
else
if (t.probs == f.probs)
if (t.pena < f.pena) return true;
else
if (t.pena == f.pena) return t.team < f.team;
return false;
}
int t, n;
string s;
unordered_map<int, bool> ac[101];
unordered_map<int, int> pena[101];
void process(bool end_line=false){
for(int i=1; i<=100; i++) ac[i].clear();
for(int i=1; i<=100; i++) pena[i].clear();
unordered_map<int, bool> submit;
sort(a+1, a+1+n, incomp);
for(int i=1; i<=n; i++){
input x = a[i];
submit[x.team]= true;
if (ac[x.team].count(x.prob)) continue;
if (x.state == "I") pena[x.team][x.prob]+=1;
if (x.state == "C"){
pena[x.team][x.prob]= (pena[x.team][x.prob]*20) + x.time;
ac[x.team][x.prob]= true;
}
}
n= 0;
for(int i=1; i<=100; i++)
if (submit[i]){
output y;
for(int j=1; j<=9; j++)
if (ac[i].count(j)) y.pena += pena[i][j];
y.team= i;
y.probs= ac[i].size();
b[++n]= y;
}
sort(b+1, b+1+n, outcomp);
for(int i=1; i<=n; i++)
cout<<b[i].team<<" "<<b[i].probs<<" "<<b[i].pena<<"\n";
if (!end_line) cout<<"\n";
}
int main(){
cin >> t; cin.ignore();
t+=1;
while(t--){
while(getline(cin, s)){
if (s==""){
if (n>0) process(t==0);
n= 0;
break;
}
n++;
string x="";
vector<string> v;
s+=' ';
for(int i=0; s[i]; i++){
if (s[i]==' '){
v.push_back(x);
x="";
continue;
}
x += s[i];
}
a[n].team= stoi(v[0]);
a[n].prob= stoi(v[1]);
a[n].time= stoi(v[2]);
a[n].state= v[3];
}
}
process(true);
}
No comments:
Post a Comment