fork(38) download
  1. /*
  2.  
  3. You need your max_rating, current_rating and last 3 rounds rating changes.
  4.  
  5. Enter the numbers in this order:
  6.  
  7. max_rating
  8. current_rating
  9. ratings_change1
  10. ratings_change2
  11. ratings_change3
  12. lucky_number
  13.  
  14.  
  15. Sit back and get your rating prediction for as long as you are not satisfied with it.
  16.  
  17. */
  18.  
  19.  
  20. #include<bits/stdc++.h>
  21. using namespace std;
  22. // #pragma GCC optimize "trapv"
  23.  
  24.  
  25. const int SEED_ACCEPTANCE_LT = 10;
  26. const int MULT_ACCEPTANCE_LT = 301;
  27. const int COUNT_PREV_CONTEST_DELTA = 3;
  28. const int MULTIPLIER = 10;
  29. const int UPP_LIM_FOR_MUL = 1000;
  30. const int MAX_RATING_SO_FAR = 3797;
  31. const int MY_FAV_REDUCING_AGENT = -3;
  32.  
  33. // 12
  34. string title_on_rating[] = {
  35. "Undated",
  36. "Noobie",
  37. "Puppy-lil", "Spicy-list", "Eggs-puff",
  38. "Candyman-Disaster", "Maatsaab", "Entertainment-Mstrbator",
  39. "Grandma's Sister", "Indigenous Gangbastad", "Legendary Grandma",
  40. "Insanity"
  41. };
  42.  
  43. int ratings_list [] = {
  44. 1,
  45. 1200, 1400, 1600,
  46. 1900, 2100, 2300,
  47. 2400, 2600, 3000, MAX_RATING_SO_FAR+1,
  48. 10000
  49. };
  50.  
  51. class Rating {
  52. public:
  53. int maxRating = 0, currRating = 0;
  54. int predictedRating = 0;
  55. int testCases = 1;
  56. int curr_rank = 0;
  57.  
  58. vector<int> prev_rating_deltas;
  59.  
  60. Rating (int r1, int r2) {
  61. maxRating = r1, currRating = r2;
  62. predictedRating = r2;
  63. curr_rank = (int)(upper_bound(ratings_list, ratings_list+12, currRating) - ratings_list);
  64. }
  65.  
  66. void Get_PastRatings() {
  67. prev_rating_deltas.resize(COUNT_PREV_CONTEST_DELTA);
  68. cout << "Enter the ratings delta of past " << COUNT_PREV_CONTEST_DELTA << " contests:\n";
  69. bool rainboy_flag = false;
  70. for (int i = 0; i < COUNT_PREV_CONTEST_DELTA; i++) {
  71. cin >> prev_rating_deltas[i];
  72. rainboy_flag |= (abs(prev_rating_deltas[i]) >= 111);
  73. }
  74. if (rainboy_flag) cout << "\"rainboy delta is detected\"\n";
  75. sort(prev_rating_deltas.begin(), prev_rating_deltas.end());
  76. if (prev_rating_deltas[0] > 0) {
  77. prev_rating_deltas[0] = - prev_rating_deltas[0];
  78. }
  79. if (prev_rating_deltas[COUNT_PREV_CONTEST_DELTA-1] < 0) {
  80. prev_rating_deltas[COUNT_PREV_CONTEST_DELTA-1] = - prev_rating_deltas[COUNT_PREV_CONTEST_DELTA-1];
  81. }
  82.  
  83. }
  84.  
  85. void Set_TestCases() {
  86. cout << "Enter your lucky number duh\n";
  87. cin >> testCases;
  88. testCases = (testCases % 9) + 1;
  89. testCases *= MULTIPLIER;
  90. }
  91.  
  92. void Prediction_Process() {
  93. vector<int> predicted_n_ratings(testCases);
  94. vector<long long> seeds(2);
  95. for (long long &seed: seeds) {
  96. seed = rand() % SEED_ACCEPTANCE_LT + 1;
  97. }
  98. while (seeds[0] == seeds[1]) {
  99. seeds[0] = rand() % SEED_ACCEPTANCE_LT + 1;
  100. }
  101. for (int tc = 0; tc < testCases; tc++) {
  102.  
  103. int thisRating =
  104. (int)(
  105. (seeds[0] * currRating + seeds[1] * maxRating)
  106. /
  107. (seeds[0] + seeds[1])
  108. );
  109.  
  110. vector<long long> multipliers_for_prev_rounds(COUNT_PREV_CONTEST_DELTA);
  111. for (long long &mult: multipliers_for_prev_rounds) {
  112. mult = rand() % UPP_LIM_FOR_MUL + 1;
  113. }
  114.  
  115. sort(multipliers_for_prev_rounds.begin(), multipliers_for_prev_rounds.end());
  116. int medianPos = COUNT_PREV_CONTEST_DELTA / 2;
  117. for (int cc = 0; cc < COUNT_PREV_CONTEST_DELTA; cc++) {
  118. while (llabs(multipliers_for_prev_rounds[cc] - multipliers_for_prev_rounds[medianPos]) > MULT_ACCEPTANCE_LT) {
  119. multipliers_for_prev_rounds[cc] = rand() % UPP_LIM_FOR_MUL + 1;
  120. }
  121. sort(multipliers_for_prev_rounds.begin(), multipliers_for_prev_rounds.end());
  122. }
  123.  
  124. long long resultantRatingDelta = 0ll, multSum = 0ll;
  125. for (int position = 0; position < COUNT_PREV_CONTEST_DELTA; position++) {
  126. resultantRatingDelta += (multipliers_for_prev_rounds[position] * (long long) prev_rating_deltas[position]);
  127. multSum += multipliers_for_prev_rounds[position];
  128. }
  129. resultantRatingDelta /= multSum;
  130. predicted_n_ratings[tc] = thisRating + (int)resultantRatingDelta;
  131. }
  132.  
  133. // nearest neighbour like
  134. sort(predicted_n_ratings.begin(), predicted_n_ratings.end());
  135. int median1 = testCases/2, median2 = testCases/2+1;
  136. int group1_mean = predicted_n_ratings[median1], group2_mean = predicted_n_ratings[median2];
  137. int group1_nos = 1, group2_nos = 1;
  138. long long sophisticated_sum1 = 0ll, sophisticated_sum2 = 0ll;
  139.  
  140. for (int i = 0; i < testCases; i++) {
  141. if (abs(group1_mean - predicted_n_ratings[i]) < abs(group2_mean - predicted_n_ratings[i])) {
  142. if (abs(group1_mean - predicted_n_ratings[i]) < MULT_ACCEPTANCE_LT) {
  143. group1_mean = (int)((long long)group1_mean + predicted_n_ratings[i]) / 2;
  144. sophisticated_sum1 += predicted_n_ratings[i];
  145. group1_nos++;
  146. }
  147. } else {
  148. if (abs(group2_mean - predicted_n_ratings[i]) < MULT_ACCEPTANCE_LT) {
  149. group2_mean = (int)((long long)group2_mean + predicted_n_ratings[i]) / 2;
  150. sophisticated_sum2 += predicted_n_ratings[i];
  151. group2_nos++;
  152. }
  153. }
  154. }
  155. int KNN_like_mean =
  156. (int) (
  157. ((long long)(group1_mean) * group1_nos + (long long) (group2_mean) * group2_nos)
  158. /
  159. (long long)(group2_nos + group1_nos)
  160. );
  161. int sophisticated_like_mean =
  162. (int) (((sophisticated_sum1 / group1_nos + sophisticated_sum2 / group2_nos)) / 2
  163. );
  164.  
  165. // cout << ".\n[KNN_like_mean: " << KNN_like_mean << "] & [sophisticated_like_mean: " << sophisticated_like_mean << "]\n";
  166. if (sophisticated_like_mean > KNN_like_mean) {
  167. swap(sophisticated_like_mean, KNN_like_mean);
  168. }
  169. sort(seeds.begin(), seeds.end());
  170. int KEN_MULTIPLIER = (rand() % MULT_ACCEPTANCE_LT) + MULTIPLIER;
  171. int XEN_MULTIPLIER = (rand() % KEN_MULTIPLIER) / 2 + 1;
  172.  
  173. predictedRating =
  174. (int)(
  175. ((XEN_MULTIPLIER * seeds[0] * sophisticated_like_mean) + (KEN_MULTIPLIER * seeds[1] * KNN_like_mean))
  176. /
  177. (((XEN_MULTIPLIER * seeds[0])) + (KEN_MULTIPLIER * seeds[1]))
  178. );
  179. }
  180.  
  181. void Analysis() {
  182. cout
  183. << "Your are currently "
  184. << title_on_rating[curr_rank]
  185. << ".\nA little bit of push and you're gonna make it to next level.\n"
  186. << title_on_rating[curr_rank+1]
  187. << " is not too far from you. WH!GL!\n";
  188. // cout << curr_rank << ratings_list[curr_rank] << "\n";
  189. }
  190.  
  191. void Challenge() {
  192. const int maxContestSoFar = 1539;
  193. string url_to_problem = "https://c...content-available-to-author-only...s.com/problemset/problem/";
  194. cout << "\nA random challenge for you is to solve the following problem\n";
  195. cout << url_to_problem << rand() % maxContestSoFar + 1 << "/" << char('A' + (curr_rank + 1) / 2) << "\n";
  196. cout << "(If this link is invalid, the number you entered was not lucky...)\n";
  197.  
  198. }
  199. };
  200.  
  201. signed main() {
  202. // random random everywhere.
  203. srand(unsigned(time(0)));
  204.  
  205. #ifdef LUCTIVUD
  206. // const auto start_time = std::chrono::high_resolution_clock::now();
  207. freopen("/home/luctivud/CPPractice/Zinput.txt", "r", stdin);
  208. freopen("/home/luctivud/CPPractice/Zoutput.txt", "w", stdout);
  209. #endif
  210.  
  211. // enter currRating and maxRating
  212. int maxR, currR;
  213. cout << "Enter your *max rating* and *current rating* respectively\n";
  214. cin >> maxR >> currR;
  215.  
  216. // validation of Rating
  217. if (maxR < currR) {
  218. cout << "Your max rating is less than your current rating.. What have you done, dumbass??\n";
  219. return 0;
  220. } else if (maxR > MAX_RATING_SO_FAR) {
  221. cout << "Unfortunately, No one is interested in your insane shit. :P\n";
  222. }
  223.  
  224. // create rating object
  225. Rating userRating(maxR, currR);
  226.  
  227. // get past ratings
  228. userRating.Get_PastRatings();
  229.  
  230. // predict Ratings:
  231. userRating.Set_TestCases();
  232. userRating.Prediction_Process();
  233.  
  234. // output ratings;
  235. cout << "\n.\n..\n...\n";
  236. cout << "Your *predicted rating* after next few rounds is: " << userRating.predictedRating;// << "\n";
  237. cout << "\n...\n..\n.\n";
  238.  
  239. userRating.Analysis();
  240. userRating.Challenge();
  241.  
  242. return 0;
  243. }
Success #stdin #stdout 0.01s 5660KB
stdin
1554 1498
20
69
-54
8
stdout
Enter your *max rating* and *current rating* respectively
Enter the ratings delta of past 3 contests:
Enter your lucky number duh

.
..
...
Your *predicted rating* after next few rounds is: 1549
...
..
.
Your are currently Spicy-list.
A little bit of push and you're gonna make it to next level.
Eggs-puff is not too far from you. WH!GL!

A random challenge for you is to solve the following problem
https://c...content-available-to-author-only...s.com/problemset/problem/308/C
(If this link is invalid, the number you entered was not lucky...)