fork download
  1. /**
  2.  * code generated by JHelper
  3.  * More info: https://g...content-available-to-author-only...b.com/AlexeyDmitriev/JHelper
  4.  * @author RiaD
  5.  */
  6.  
  7. #include <iostream>
  8. #include <fstream>
  9.  
  10. #include <iostream>
  11. #include <cassert>
  12. #include <deque>
  13. #include <iomanip>
  14. #include <vector>
  15. #include <array>
  16. #include <algorithm>
  17.  
  18.  
  19. #include <iterator>
  20.  
  21.  
  22. #include <string>
  23. #include <stdexcept>
  24.  
  25. #ifndef SPCPPL_ASSERT
  26. #ifdef SPCPPL_DEBUG
  27. #define SPCPPL_ASSERT(condition) \
  28. if(!(condition)) { \
  29. throw std::runtime_error(std::string() + #condition + " in line " + std::to_string(__LINE__) + " in " + __PRETTY_FUNCTION__); \
  30. }
  31. #else
  32. #define SPCPPL_ASSERT(condition)
  33. #endif
  34. #endif
  35.  
  36.  
  37. /**
  38. * Support decrementing and multi-passing, but not declared bidirectional(or even forward) because
  39. * it's reference type is not a reference.
  40. *
  41. * It doesn't return reference because
  42. * 1. Anyway it'll not satisfy requirement [forward.iterators]/6
  43. * If a and b are both dereferenceable, then a == b if and only if *a and
  44. * b are bound to the same object.
  45. * 2. It'll not work with reverse_iterator that returns operator * of temporary which is temporary for this iterator
  46. *
  47. * Note, reverse_iterator is not guaranteed to work now too since it works only with bidirectional iterators,
  48. * but it's seems to work at least on my implementation.
  49. *
  50. * It's not really useful anywhere except iterating anyway.
  51. */
  52. template <typename T>
  53. class IntegerIterator {
  54. public:
  55. using value_type = T;
  56. using difference_type = std::ptrdiff_t;
  57. using pointer = T*;
  58. using reference = T;
  59. using iterator_category = std::input_iterator_tag;
  60.  
  61. explicit IntegerIterator(T value): value(value) {
  62.  
  63. }
  64.  
  65. IntegerIterator& operator++() {
  66. ++value;
  67. return *this;
  68. }
  69.  
  70. IntegerIterator operator++(int) {
  71. IntegerIterator copy = *this;
  72. ++value;
  73. return copy;
  74. }
  75.  
  76. IntegerIterator& operator--() {
  77. --value;
  78. return *this;
  79. }
  80.  
  81. IntegerIterator operator--(int) {
  82. IntegerIterator copy = *this;
  83. --value;
  84. return copy;
  85. }
  86.  
  87. T operator*() const {
  88. return value;
  89. }
  90.  
  91. bool operator==(IntegerIterator rhs) const {
  92. return value == rhs.value;
  93. }
  94.  
  95. bool operator!=(IntegerIterator rhs) const {
  96. return !(*this == rhs);
  97. }
  98.  
  99. private:
  100. T value;
  101. };
  102.  
  103. template <typename T>
  104. class IntegerRange {
  105. public:
  106. IntegerRange(T begin, T end): begin_(begin), end_(end) {
  107. SPCPPL_ASSERT(begin <= end);
  108. }
  109.  
  110. IntegerIterator<T> begin() const {
  111. return IntegerIterator<T>(begin_);
  112. }
  113.  
  114. IntegerIterator<T> end() const {
  115. return IntegerIterator<T>(end_);
  116. }
  117.  
  118. private:
  119. T begin_;
  120. T end_;
  121. };
  122.  
  123. template <typename T>
  124. class ReversedIntegerRange {
  125. using IteratorType = std::reverse_iterator<IntegerIterator<T>>;
  126. public:
  127. ReversedIntegerRange(T begin, T end): begin_(begin), end_(end) {
  128. SPCPPL_ASSERT(begin >= end);
  129. }
  130.  
  131. IteratorType begin() const {
  132. return IteratorType(IntegerIterator<T>(begin_));
  133. }
  134.  
  135. IteratorType end() const {
  136. return IteratorType(IntegerIterator<T>(end_));
  137. }
  138.  
  139. private:
  140. T begin_;
  141. T end_;
  142. };
  143.  
  144. template <typename T>
  145. IntegerRange<T> range(T to) {
  146. return IntegerRange<T>(0, to);
  147. }
  148.  
  149. template <typename T>
  150. IntegerRange<T> range(T from, T to) {
  151. return IntegerRange<T>(from, to);
  152. }
  153.  
  154. template <typename T>
  155. IntegerRange<T> inclusiveRange(T to) {
  156. return IntegerRange<T>(0, to + 1);
  157. }
  158.  
  159. template <typename T>
  160. IntegerRange<T> inclusiveRange(T from, T to) {
  161. return IntegerRange<T>(from, to + 1);
  162. }
  163.  
  164. template <typename T>
  165. ReversedIntegerRange<T> downrange(T from) {
  166. return ReversedIntegerRange<T>(from, 0);
  167. }
  168.  
  169. template <typename T>
  170. ReversedIntegerRange<T> downrange(T from, T to) {
  171. return ReversedIntegerRange<T>(from, to);
  172. }
  173.  
  174. template <typename T>
  175. ReversedIntegerRange<T> inclusiveDownrange(T from) {
  176. return ReversedIntegerRange<T>(from + 1, 0);
  177. }
  178.  
  179. template <typename T>
  180. ReversedIntegerRange<T> inclusiveDownrange(T from, T to) {
  181. return ReversedIntegerRange<T>(from + 1, to);
  182. }
  183.  
  184. //#define PROBLEM "problem_name.h"
  185. //#include PROBLEM
  186. //#include <message.h>
  187. //#include <spcppl/dgcj.h>
  188.  
  189. using namespace std;
  190.  
  191. class Khokkei {
  192. public:
  193. static constexpr int kStressCount = 0;
  194.  
  195. static void generateTest(std::ostream& test) {
  196. }
  197.  
  198. void solve(std::istream& in, std::ostream& out) {
  199. //static int testnumber = 0;
  200. //out << "Case #" << ++testnumber << ": ";
  201. //cerr << "test " << testnumber << endl;
  202. int n;
  203. in >> n;
  204. deque<int> minors[2];
  205. deque<int> majors[2];
  206.  
  207. array<array<int, 6>, 6> times{};
  208.  
  209. int old_time = 0;
  210. auto add = [&](int rt) {
  211. //cerr << old_time / 600 << ":" << old_time % 600 << " " << rt / 600 << ":" << rt % 600 << " "
  212. // << 5 - minors[0].size() - majors[0].size() << "x" << 5 - minors[1].size() - majors[1].size() << endl;
  213. times[5 - minors[0].size() - majors[0].size()][5 - minors[1].size() - majors[1].size()] += rt - old_time;
  214. old_time = rt;
  215. };
  216. auto process = [&](int rt) {
  217. while (true) {
  218. int mn = rt;
  219. for (auto* ar: {&minors, &majors}) {
  220. for (int i: range(2)) {
  221. auto& c = (*ar)[i];
  222. if (!c.empty()) {
  223. mn = min(mn, c.front());
  224. }
  225. }
  226. }
  227. add(mn);
  228. for (auto* ar: {&minors, &majors}) {
  229. for (int i: range(2)) {
  230. auto& c = (*ar)[i];
  231. while (!c.empty() && c.front() == mn) {
  232. c.pop_front();
  233. }
  234. }
  235. }
  236.  
  237. if (mn == rt) {
  238. return;
  239. }
  240. }
  241. };
  242. auto goal = [&](int time, int team) {
  243. //cerr << time / 600 << ":" << time %600 << " "<< minors[0].size() << " " << minors[1].size() << "\n";
  244. if (minors[team].size() + majors[team].size() < minors[!team].size() + majors[!team].size()) {
  245. if (!minors[!team].empty()) {
  246. minors[!team].pop_front();
  247. }
  248. }
  249. };
  250.  
  251. for (int i: range(n)) {
  252. string s;
  253. in >> s;
  254. int team;
  255. string type;
  256. in >> team >> type;
  257. --team;
  258.  
  259. int rt = (((s[0] - '0') * 10 + s[1] - '0') * 60 + (s[3] - '0') * 10 + (s[4] - '0')) * 10 + s[6] - '0';
  260. process(rt);
  261. if (type == "goal") {
  262. goal(rt, team);
  263. }
  264. else if (type == "minor") {
  265. minors[team].push_back(rt + 2 * 60 * 10);
  266. }
  267. else if (type == "major") {
  268. majors[team].push_back(rt + 5 * 60 * 10);
  269. }
  270. else {
  271. assert(false);
  272. }
  273. }
  274. process(60 * 60 * 10);
  275.  
  276.  
  277. for (int i: inclusiveRange(0, 5)) {
  278. for (int j: inclusiveRange(0, 5)) {
  279. if (times[i][j]) {
  280. int t = times[i][j];
  281. out << i << "x" << j << " " << setfill('0') << setw(2) << (t / 10 / 60) << ":" << setfill('0') << setw(2) << (t / 10 % 60) << "." << setw(1) << (t % 10) << "\n";
  282. }
  283. }
  284. }
  285. }
  286. };
  287.  
  288.  
  289. int main() {
  290. std::ios_base::sync_with_stdio(false);
  291. Khokkei solver;
  292. std::istream& in(std::cin);
  293. std::ostream& out(std::cout);
  294. in.tie(nullptr);
  295. out << std::fixed;
  296. out.precision(20);
  297. solver.solve(in, out);
  298. return 0;
  299. }
  300.  
Runtime error #stdin #stdout #stderr 0s 5632KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
prog: prog.cpp:271: void Khokkei::solve(std::istream&, std::ostream&): Assertion `false' failed.