fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <algorithm>
  4. #include <cmath>
  5. #include <climits>
  6. #include <iomanip>
  7. #include <vector>
  8. #include <stack>
  9. #include <queue>
  10. #include <map>
  11. #include <unordered_map>
  12. #include <list>
  13. #include <set>
  14. #include <unordered_set>
  15. #include <bitset>
  16. #include <typeinfo>
  17. using namespace std;
  18. // P.Moriarty //
  19. #define Moriary ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  20. using ll = long long;
  21. long long fac(int n)
  22. {
  23. long long fact = 1;
  24. for (int i = 1;i <= n;i++)
  25. {
  26. fact *= i;
  27. }
  28. return fact;
  29. }
  30. long long per(int n, int j)
  31. {
  32. long long p = 1;
  33. for (int i = n; i > n - j; i--)
  34. {
  35. p *= i;
  36. }
  37. return p;
  38. }
  39. bool lucky(int ch)
  40. {
  41. bool l = true;
  42.  
  43. while (ch > 0)
  44. {
  45. int d = ch % 10;
  46. if (d == 7 || d == 4)
  47. {
  48. ch /= 10;
  49. }
  50. else
  51. {
  52. l = false;
  53. break;
  54. }
  55. }
  56.  
  57. return l;
  58.  
  59. }
  60. long long pro(long long i)
  61. {
  62. long long r = 1;
  63. for (int j = 1;j <= i;j++)
  64. {
  65. r *= 10;
  66. }
  67. return r;
  68. }
  69.  
  70. bool prime(int x) {
  71. if (x <= 1) return false;
  72. if (x == 2 || x == 3) return true;
  73. if (x % 2 == 0 || x % 3 == 0) return false;
  74.  
  75. for (int i = 5; i <= sqrt(x); i += 6) {
  76. if (x % i == 0 || x % (i + 2) == 0) return false;
  77. }
  78.  
  79. return true;
  80. }
  81.  
  82. int f(string a, string b)
  83. {
  84. int c = 0;
  85. for (int i = 0;i < a.size();i++)
  86. {
  87. if (a[i] == b[i])
  88. c++;
  89. }
  90. return c;
  91. }
  92. string bit_2(int x)
  93. {
  94. string r;
  95. while (x != 0)
  96. {
  97. if (x % 2 == 0)
  98. r += '0';
  99. else
  100. r += '1';
  101. x /= 2;
  102. }
  103. return r;
  104. }
  105. int digit_sum(int n)
  106. {
  107. int sum = 0;
  108. while (n > 0) {
  109. sum += n % 10;
  110. n /= 10;
  111. }
  112. return sum;
  113. }
  114. int gcd(int a, int b) {
  115. while (b != 0) {
  116. int temp = b;
  117. b = a % b;
  118. a = temp;
  119. }
  120. return a;
  121. }
  122. bool BIN(vector<int>& a, int x)
  123. {
  124. int l = 0, r = a.size() - 1;
  125. while (l <= r) {
  126. int mid = (l + r) / 2;
  127. if (a[mid] == x)
  128. return true;
  129. else
  130. if (a[mid] < x) l = mid + 1;
  131. else r = mid - 1;
  132. }
  133. return false;
  134. }
  135.  
  136.  
  137. bool countbits(int a)
  138. {
  139. int x = a;
  140. int count = 0;
  141. bool ch = true;
  142. while (x)
  143. {
  144. for (int i = 60; i >= 0; --i)
  145. {
  146. if (((x >> i) & 1) == 0)
  147. count++;
  148. if (count > 1)
  149. {
  150. break;
  151. ch = false;
  152. }
  153.  
  154. }
  155.  
  156. }
  157. return ch;
  158. }
  159.  
  160. int ones_up_to(int x, int b) {
  161. if (x < 0) return 0;
  162. int cycle = 1 << (b + 1);
  163. int full_cycles = (x + 1) / cycle;
  164. int rem = (x + 1) % cycle;
  165. int ones = full_cycles * (1 << b);
  166. ones += max(0, rem - (1 << b));
  167. return ones;
  168. }
  169. string solve(int l, int r)
  170. {
  171. int a = l ^ r;
  172. string ans;
  173. while (a)
  174. {
  175. if (a & 1)
  176. {
  177. ans += "0";
  178. }
  179. else
  180. ans += "1";
  181. a >>= 1;
  182. }
  183. return ans;
  184. }
  185. bool check_palindrom(string s)
  186. {
  187. string t = s;
  188. reverse(t.begin(), t.end());
  189. return s == t;
  190. }
  191.  
  192. bool check_order(string s)
  193. {
  194. for (int i = 1; i < s.size(); i++)
  195. {
  196. if (s[i] < s[i - 1]) return false;
  197. }
  198. return true;
  199. }
  200.  
  201.  
  202. int main()
  203. {
  204. Moriary;
  205. int t;
  206. cin >> t;
  207. int r = t;
  208. map<string, float >m;
  209. while (t--)
  210. {
  211. int n;
  212. cin >> n;
  213. float point = 1000.0;
  214. for (int i = 0;i < n;i++)
  215. {
  216. string s;
  217. cin >> s;
  218. m[s] += point;
  219. point *= 0.9;
  220. }
  221. }
  222. vector<pair<float, string>>arr;
  223. for (auto p : m)
  224. {
  225. arr.push_back({ p.second, p.first });
  226. }
  227. sort(arr.begin(), arr.end(), [](const pair<float, string>& a, const pair<float, string>& b) {
  228. if (a.first != b.first)
  229. return a.first > b.first;
  230. return a.second < b.second;
  231. });
  232. for (int i = 0;i < arr.size();i++)
  233. {
  234. if (i == 0)
  235. {
  236. cout << arr[i].second<<endl;
  237. }
  238. int v = int(arr[i].first);
  239. if (arr[i].first - v >= 0.5)
  240. v++;
  241. cout << arr[i].second<<" "<< v << endl;
  242.  
  243. }
  244.  
  245.  
  246. }
Success #stdin #stdout 0.01s 5320KB
stdin
Standard input is empty
stdout
Standard output is empty