fork(1) download
  1. #include <bits/stdc++.h>
  2.  
  3. typedef long long LL;
  4. typedef double DB;
  5.  
  6. #define sf scanf
  7. #define pf printf
  8. #define mp make_pair
  9. #define nl printf("\n")
  10.  
  11. #define FOR(i,a,b) for(i = a; i <= b; ++i)
  12. #define FORD(i,a,b) for(i = a; i >= b; --i)
  13. #define FORS(i,n) for(i = 0; i < n; ++i)
  14. #define FORM(i,n) for(i = n - 1; i >= 0; --i)
  15. #define reset(i,n) memset(i, n, sizeof(i))
  16. #define open freopen("input.txt","r",stdin); freopen("output.txt","w",stdout)
  17. #define close fclose(stdin); fclose(stdout)
  18.  
  19. using namespace std;
  20.  
  21. const LL mod = 1e9 + 7;
  22. const LL INF = 4e18;
  23. const int inf = 2e9;
  24.  
  25. int gcd(int a, int b) { return b? gcd(b, a%b): a; }
  26. int lcm(int a, int b) { return a/ gcd(a, b)*b; }
  27.  
  28. struct score {
  29. int ac;
  30. int time;
  31. };
  32.  
  33. struct team {
  34. string name;
  35. bool done[10];
  36. int tried[10];
  37. int totalTime;
  38. score log[301];
  39. };
  40.  
  41. inline bool cmp(team l, team r) {
  42. int i;
  43. FORD(i, 300, 1) {
  44. if(l.log[i].ac != r.log[i].ac) return l.log[i].ac > r.log[i].ac;
  45. if(l.log[i].time != r.log[i].time) return l.log[i].time < r.log[i].time;
  46. }
  47. return l.totalTime > r.totalTime;
  48. }
  49.  
  50. inline bool same(team l, team r) {
  51. int i;
  52. FORD(i, 300, 1) {
  53. if(l.log[i].ac != r.log[i].ac) return 0;
  54. if(l.log[i].time != r.log[i].time) return 0;
  55. }
  56. return 1;
  57. }
  58.  
  59. team a[55];
  60. map<string, int> m;
  61.  
  62. int main(void)
  63. {
  64. ios_base::sync_with_stdio(false);
  65. int t, i, j, n, q, qq;
  66. cin >> t;
  67. while(t--) {
  68. m.clear();
  69. cin >> n >> q;
  70. FORS(i, 55) {
  71. FORS(j, 10) {
  72. a[i].done[j] = 0;
  73. a[i].tried[j] = 0;
  74. }
  75. a[i].totalTime = 0;
  76. FORS(j, 301) {
  77. a[i].log[j].ac = 0;
  78. a[i].log[j].time = 0;
  79. }
  80. }
  81. FOR(i, 1, n) {
  82. cin >> a[i].name;
  83. m[a[i].name] = i;
  84. }
  85. FOR(qq, 1, q) {
  86. int time;
  87. string nama, verdi;
  88. char prob;
  89. cin >> time >> nama >> prob;
  90. while(prob < 'A' || 'J' < prob) cin >> prob;
  91. prob -= 'A';
  92. cin >> verdi;
  93.  
  94. int id = m[nama];
  95. if(a[id].done[prob]) continue;
  96. if(verdi[0] == 'a') {
  97. a[id].done[prob] = 1;
  98. int add = time + 20 * a[id].tried[prob];
  99. a[id].log[time].ac++;
  100. a[id].log[time].time += add;
  101. } else a[id].tried[prob]++;
  102.  
  103. a[id].totalTime += time;
  104. }
  105. FOR(i, 1, n) FOR(j, 1, 300) {
  106. a[i].log[j].ac += a[i].log[j - 1].ac;
  107. a[i].log[j].time += a[i].log[j - 1].time;
  108. }
  109.  
  110. sort(a + 1, a + 1 + n, cmp);
  111. int last;
  112. FOR(i, 1, n) {
  113. if(i == 1 || !same(a[i], a[i - 1])) last = i;
  114. cout << last << ' ' << a[i].name << ' ';
  115. cout << a[i].log[300].ac << ' ' << a[i].log[300].time << '\n';
  116. }
  117. }
  118.  
  119. return 0;
  120. }
  121.  
Success #stdin #stdout 0s 3588KB
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