Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define ll long long
- #define endl '\n'
- #define sz(x) int(x.size())
- #define all(x) x.begin(), x.end()
- struct Status {
- bool solved;
- int penality;
- Status() {
- solved = false;
- penality = 0;
- }
- };
- struct Judge {
- int contestant;
- vector<Status> problems;
- bool participating;
- Judge() {
- participating = false;
- problems.assign(10, Status());
- }
- int solved_problems() const {
- int cnt = 0;
- for (int i = 1; i <= 9; i++) cnt += problems[i].solved;
- return cnt;
- }
- int penality() const {
- int pena = 0;
- for (int i = 1; i <= 9; i++) {
- pena += (problems[i].solved * problems[i].penality);
- }
- return pena;
- }
- bool operator<(Judge const & rhs) {
- int cnt_i = solved_problems(), cnt_r = rhs.solved_problems();
- return cnt_i > cnt_r || ((cnt_i == cnt_r && penality() < rhs.penality()) || (penality() == rhs.penality() && contestant < rhs.contestant));
- }
- };
- int main() {
- ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
- int test;
- cin >> test;
- cin.ignore();
- cin.ignore();
- int cnt = 0;
- while (test--) {
- if (cnt++) cout << endl;
- vector<Judge> standing(105);
- string s;
- while (getline(cin, s), isdigit(s[0])) {
- stringstream ss(s);
- int person, problem, time;
- char L;
- ss >> person >> problem >> time >> L;
- standing[person].participating = true;
- standing[person].contestant = person;
- if (L == 'C') {
- if (standing[person].problems[problem].solved) continue;
- standing[person].problems[problem].solved = true;
- standing[person].problems[problem].penality += time;
- }
- else if (L == 'I') {
- if (standing[person].problems[problem].solved) continue;
- standing[person].problems[problem].penality += 20;
- }
- }
- sort(all(standing));
- for (int i = 0; i < 105; i++) {
- if (standing[i].participating) {
- cout << standing[i].contestant << " " << standing[i].solved_problems() << " " << standing[i].penality() << endl;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement