fork download
  1. #include <set>
  2. #include <map>
  3. #include <list>
  4. #include <cmath>
  5. #include <queue>
  6. #include <stack>
  7. #include <cstdio>
  8. #include <string>
  9. #include <vector>
  10. #include <cstdlib>
  11. #include <cstring>
  12. #include <sstream>
  13. #include <iomanip>
  14. #include <complex>
  15. #include <iostream>
  16. #include <algorithm>
  17.  
  18. #include <ctime>
  19. #include <deque>
  20. #include <bitset>
  21. #include <cctype>
  22. #include <utility>
  23. #include <cassert>
  24. using namespace std;
  25.  
  26. #define FOR(i,a,b) for(int i=(a),_b=(b); i<=_b; i++)
  27. #define FORD(i,a,b) for(int i=(a),_b=(b); i>=_b; i--)
  28. #define REP(i,a) for(int i=0,_a=(a); i<_a; i++)
  29. #define EACH(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)
  30.  
  31. #define DEBUG(x) { cout << #x << " = " << x << endl; }
  32. #define PR(a,n) { cout << #a << " = "; FOR(_,1,n) cout << a[_] << ' '; cout << endl; }
  33. #define PR0(a,n) { cout << #a << " = "; REP(_,n) cout << a[_] << ' '; cout << endl; }
  34.  
  35. struct Team {
  36. string name;
  37. int nWrong[22];
  38. bool accepted[22];
  39. int penalty, nAc;
  40. vector<pair<int,int> > scores;
  41.  
  42. Team(string name = "") : name(name) {
  43. memset(nWrong, 0, sizeof nWrong);
  44. memset(accepted, false, sizeof accepted);
  45. penalty = nAc = 0;
  46. scores.clear();
  47. }
  48.  
  49. void submit(int t, int prob, string status) {
  50. if (accepted[prob]) return ;
  51.  
  52. if (status[0] == 'a') {
  53. penalty += nWrong[prob] * 20 + t;
  54. accepted[prob] = true;
  55. ++nAc;
  56. scores.push_back(make_pair(t, penalty));
  57. }
  58. else {
  59. ++nWrong[prob];
  60. }
  61. }
  62. } teams[55];
  63.  
  64. bool lower(const Team &a, const Team &b) {
  65. if (a.nAc != b.nAc) return a.nAc > b.nAc;
  66. if (a.penalty != b.penalty) return a.penalty < b.penalty;
  67. FORD(i,a.scores.size()-1,0)
  68. if (a.scores[i].first < b.scores[i].first) return true;
  69. else if (a.scores[i].first > b.scores[i].first) return false;
  70. else if (a.scores[i].second != b.scores[i].second)
  71. return a.scores[i].second < b.scores[i].second;
  72. return false;
  73. }
  74.  
  75. bool operator < (const Team &a, const Team &b) {
  76. if (a.nAc != b.nAc) return a.nAc > b.nAc;
  77. if (a.penalty != b.penalty) return a.penalty < b.penalty;
  78. FORD(i,a.scores.size()-1,0)
  79. if (a.scores[i].first < b.scores[i].first) return true;
  80. else if (a.scores[i].first > b.scores[i].first) return false;
  81. else if (a.scores[i].second != b.scores[i].second)
  82. return a.scores[i].second < b.scores[i].second;
  83. return a.name < b.name;
  84. }
  85.  
  86. int nTeam, nSub;
  87. #define rank rank_
  88. int rank[55];
  89.  
  90. int getId(string name) {
  91. FOR(i,1,nTeam)
  92. if (teams[i].name == name) return i;
  93. return -1;
  94. }
  95.  
  96. int main() {
  97. ios :: sync_with_stdio(false); cin.tie(NULL);
  98. cout << (fixed) << setprecision(6);
  99. int ntest; cin >> ntest;
  100. while (ntest--) {
  101. cin >> nTeam >> nSub;
  102. FOR(i,1,nTeam) {
  103. string s; cin >> s;
  104. teams[i] = Team(s);
  105. }
  106. FOR(i,1,nSub) {
  107. int t; string name, prob, status;
  108. cin >> t >> name >> prob >> status;
  109.  
  110. int id = getId(name);
  111. teams[id].submit(t, prob[0] - 'A', status);
  112. }
  113. sort(teams+1, teams+nTeam+1);
  114.  
  115. FOR(i,1,nTeam) {
  116. if (i == 1) rank[i] = 1;
  117. else if (lower(teams[i-1], teams[i])) rank[i] = i;
  118. else rank[i] = rank[i-1];
  119. cout << rank[i] << ' ' << teams[i].name << ' ' << teams[i].nAc << ' ' << teams[i].penalty << endl;
  120. }
  121. }
  122. return 0;
  123. }
  124.  
  125.  
Success #stdin #stdout 0s 3500KB
stdin
1
8 28
twente
utrecht
groningen
amsterdam
eindhoven
leiden
delft
nijmegen
5 utrecht B rejected
8 eindhoven F accepted
10 utrecht F accepted
17 utrecht B rejected
18 leiden C rejected
23 twente F rejected
25 utrecht B accepted
26 amsterdam D rejected
27 amsterdam D accepted
27 leiden C accepted
27 groningen F accepted
28 twente F rejected
30 nijmegen C rejected
30 nijmegen C accepted
30 delft B accepted
30 delft B rejected
33 twente F accepted
47 groningen D rejected
51 leiden D accepted
51 amsterdam C accepted
51 groningen D accepted
60 utrecht D accepted
65 utrecht J accepted
67 twente F rejected
70 twente F accepted
90 eindhoven D accepted
100 utrecht A rejected
101 utrecht C rejected
stdout
1 utrecht 4 200
2 groningen 2 98
3 amsterdam 2 98
3 leiden 2 98
5 eindhoven 2 98
6 delft 1 30
7 nijmegen 1 50
8 twente 1 73