Advertisement
Guest User

Untitled

a guest
Oct 18th, 2019
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 9.93 KB | None | 0 0
  1. /*
  2. █████████████.....██████....██.........█....██████████....██.........██.
  3. ██.........██.......██......█.█........█....██......██.....██.......██..
  4. ██.........██.......██......█..█.......█....██......██......██.....██...
  5. ██.........██.......██......█...█......█....██......██.......██...██....
  6. ██.........██.......██......█....█.....█....██......██........██.██.....
  7. ██.........██.......██......█.....█....█....██......██.........███......
  8. █████████████.......██......█.....█....█....██████████.........███......
  9. ██..................██......█......█...█....██......██.........███......
  10. ██..................██......█......█...█....██......██.........███......
  11. ██..................██......█.......█..█....██......██.........███......
  12. ██..................██......█.......█..█....██......██.........███......
  13. ██..................██......█........█.█....██......██.........███......
  14. ██..................██......█........█.█....██......██.........███......
  15. ██................██████....█.........██....██......██.........███......
  16. ЗАПУСКАЕМ
  17. ░ГУСЯ░▄▀▀▀▄░РАБОТЯГУ░░
  18. ▄███▀░◐░░░▌░░░░░░░
  19. ░░░░▌░░░░░▐░░░░░░░
  20. ░░░░▐░░░░░▐░░░░░░░
  21. ░░░░▐░░░░░▐░░░░░░░
  22. ░░░░▐░░░░░▐░░░░░░░
  23. ░░░░▐░░░░░▐░░░░░░░
  24. ░░░░▐░░░░░▐░░░░░░░
  25. ░░░░▐░░░░░▐░░░░░░░
  26. ░░░░▐░░░░░▐░░░░░░░
  27. ░░░░▐░░░░░▐░░░░░░░
  28. ░░░░▌░░░░░▐▄▄░░░░░
  29. ░░░░▌░░░░▄▀▒▒▀▀▀▀▄
  30. ░░░▐░░░░▐▒▒▒▒▒▒▒▒▀▀▄
  31. ░░░▐░░░░▐▄▒▒▒▒▒▒▒▒▒▒▀▄
  32. ░░░░▀▄░░░░▀▄▒▒▒▒▒▒▒▒▒▒▀▄
  33. ░░░░░░▀▄▄▄▄▄█▄▄▄▄▄▄▄▄▄▄▄▀▄
  34. ░░░░░░░░░░░▌▌░▌▌░░░░░
  35. ░░░░░░░░░░░▌▌░▌▌░░░░░
  36. ░░░░░░░░░▄▄▌▌▄▌▌░░░░░
  37.  */
  38. #pragma GCC optimize("Ofast,no-stack-protector")
  39. #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
  40. #pragma GCC optimize("unroll-loops")
  41. #pragma GCC optimize("fast-math")
  42. #pragma GCC optimize("section-anchors")
  43. #pragma GCC optimize("profile-values,profile-reorder-functions,tracer")
  44. #pragma GCC optimize("vpt")
  45. #pragma GCC optimize("rename-registers")
  46. #pragma GCC optimize("move-loop-invariants")
  47. #pragma GCC optimize("unswitch-loops")
  48. #pragma GCC optimize("function-sections")
  49. #pragma GCC optimize("data-sections")
  50. #pragma GCC optimize("branch-target-load-optimize")
  51. #pragma GCC optimize("branch-target-load-optimize2")
  52. #pragma GCC optimize("btr-bb-exclusive")
  53. #include <iostream>
  54. #include <vector>
  55. #include <cassert>
  56. #include <cstdio>
  57. #include <algorithm>
  58. #include <iomanip>
  59. #include <tuple>
  60. #include <math.h>
  61. #include <set>
  62. #include <stack>
  63. #include <map>
  64. #include <queue>
  65. #include <random>
  66. #define pb(x) push_back(x);
  67. #define endl "\n"
  68. #define all(x) x.begin(), x.end()
  69.  // #define int long long
  70. // #define f first;
  71. // #define s second;
  72. #define DEBUG
  73.  
  74. using namespace std;
  75.  
  76. typedef long long ll;
  77. typedef unsigned long long ull;
  78. typedef long double ld;
  79. typedef vector<int> vi;
  80. typedef vector<vector<int> > vvi;
  81. typedef vector<ull> vull;
  82. typedef vector<ll> vll;
  83. typedef tuple<int, int, int> tiii;
  84. typedef pair<int, int> pii;
  85. typedef vector<pair<int, int> > vpii;
  86. typedef vector<bool> vb;
  87. typedef vector<string> vs;
  88. typedef vector< vector<int> > vvi;
  89. typedef vector<char> vc;
  90.  
  91. const int INF = 1e9;
  92. const ll INFLL = 1e12;
  93. const int MOD = 1000000007;
  94.  /**
  95.  * Author: Sergey Kopeliovich (Burunduk30@gmail.com)
  96.  */
  97.  
  98. #define VERSION "0.1.5"
  99.  
  100. /** Fast allocation */
  101.  
  102. #ifdef FAST_ALLOCATOR_MEMORY
  103.     int allocator_pos = 0;
  104.     char allocator_memory[(int)FAST_ALLOCATOR_MEMORY];
  105.     inline void * operator new ( size_t n ) {
  106.         char *res = allocator_memory + allocator_pos;
  107.         allocator_pos += n;
  108.         assert(allocator_pos <= (int)FAST_ALLOCATOR_MEMORY);
  109.         return (void *)res;
  110.     }
  111.     inline void operator delete ( void * ) noexcept { }
  112.     //inline void * operator new [] ( size_t ) { assert(0); }
  113.     //inline void operator delete [] ( void * ) { assert(0); }
  114. #endif
  115.  
  116. /** Fast input-output */
  117.  
  118. template <class T = int> inline T readInt();                        
  119. inline double readDouble();
  120. inline int readUInt();                  
  121. inline int readChar(); // first non-blank character
  122. inline void readWord( char *s );
  123. inline bool readLine( char *s ); // do not save '\n'
  124. inline bool isEof();
  125. inline int getChar();
  126. inline int peekChar();
  127. inline bool seekEof();
  128. inline void skipBlanks();
  129.  
  130. template <class T> inline void writeInt( T x, char end = 0, int len = -1 );
  131. inline void writeChar( int x );
  132. inline void writeWord( const char *s );
  133. inline void writeDouble( double x, int len = 0 );
  134. inline void flush();
  135.  
  136. static struct buffer_flusher_t {
  137.     ~buffer_flusher_t() {
  138.         flush();
  139.     }
  140. } buffer_flusher;
  141.  
  142. /** Read */
  143.  
  144. static const int buf_size = 4096;
  145.  
  146. static unsigned char buf[buf_size];
  147. static int buf_len = 0, buf_pos = 0;
  148.  
  149. inline bool isEof() {
  150.     if (buf_pos == buf_len) {
  151.         buf_pos = 0, buf_len = fread(buf, 1, buf_size, stdin);
  152.         if (buf_pos == buf_len)
  153.             return 1;
  154.     }
  155.     return 0;
  156. }
  157.  
  158. inline int getChar() {
  159.     return isEof() ? -1 : buf[buf_pos++];
  160. }
  161.  
  162. inline int peekChar() {
  163.     return isEof() ? -1 : buf[buf_pos];
  164. }
  165.  
  166. inline bool seekEof() {
  167.     int c;
  168.     while ((c = peekChar()) != -1 && c <= 32)
  169.         buf_pos++;
  170.     return c == -1;
  171. }
  172.  
  173. inline void skipBlanks() {
  174.     while (!isEof() && buf[buf_pos] <= 32U)
  175.         buf_pos++;
  176. }
  177.  
  178. inline int readChar() {
  179.     int c = getChar();
  180.     while (c != -1 && c <= 32)
  181.         c = getChar();
  182.     return c;
  183. }
  184.  
  185. inline int readUInt() {
  186.     int c = readChar(), x = 0;
  187.     while ('0' <= c && c <= '9')
  188.         x = x * 10 + c - '0', c = getChar();
  189.     return x;
  190. }
  191.  
  192. template <class T>
  193. inline T readInt() {
  194.     int s = 1, c = readChar();
  195.     T x = 0;
  196.     if (c == '-')
  197.         s = -1, c = getChar();
  198.     else if (c == '+')
  199.         c = getChar();
  200.     while ('0' <= c && c <= '9')
  201.         x = x * 10 + c - '0', c = getChar();
  202.     return s == 1 ? x : -x;
  203. }
  204.  
  205. inline double readDouble() {
  206.     int s = 1, c = readChar();
  207.     double x = 0;
  208.     if (c == '-')
  209.         s = -1, c = getChar();
  210.     while ('0' <= c && c <= '9')
  211.         x = x * 10 + c - '0', c = getChar();
  212.     if (c == '.') {
  213.         c = getChar();
  214.         double coef = 1;
  215.         while ('0' <= c && c <= '9')
  216.             x += (c - '0') * (coef *= 1e-1), c = getChar();
  217.     }
  218.     return s == 1 ? x : -x;
  219. }
  220.  
  221. inline void readWord( char *s ) {
  222.     int c = readChar();
  223.     while (c > 32)
  224.         *s++ = c, c = getChar();
  225.     *s = 0;
  226. }
  227.  
  228. inline bool readLine( char *s ) {
  229.     int c = getChar();
  230.     while (c != '\n' && c != -1)
  231.         *s++ = c, c = getChar();
  232.     *s = 0;
  233.     return c != -1;
  234. }
  235.  
  236. /** Write */
  237.  
  238. static int write_buf_pos = 0;
  239. static char write_buf[buf_size];
  240.  
  241. inline void writeChar( int x ) {
  242.     if (write_buf_pos == buf_size)
  243.         fwrite(write_buf, 1, buf_size, stdout), write_buf_pos = 0;
  244.     write_buf[write_buf_pos++] = x;
  245. }
  246.  
  247. inline void flush() {
  248.     if (write_buf_pos) {
  249.         fwrite(write_buf, 1, write_buf_pos, stdout), write_buf_pos = 0;
  250.         fflush(stdout);
  251.     }
  252. }
  253.  
  254. template <class T>
  255. inline void writeInt( T x, char end, int output_len ) {
  256.     if (x < 0)
  257.         writeChar('-'), x = -x;
  258.  
  259.     char s[24];
  260.     int n = 0;
  261.     while (x || !n)
  262.         s[n++] = '0' + x % 10, x /= 10;
  263.     while (n < output_len)
  264.         s[n++] = '0';
  265.     while (n--)
  266.         writeChar(s[n]);
  267.     if (end)
  268.         writeChar(end);
  269. }
  270.  
  271. inline void writeWord( const char *s ) {
  272.     while (*s)
  273.         writeChar(*s++);
  274. }
  275.  
  276. inline void writeDouble( double x, int output_len ) {
  277.     if (x < 0)
  278.         writeChar('-'), x = -x;
  279.     assert(x <= (1LLU << 63) - 1);
  280.     long long t = (long long)x;
  281.     writeInt(t), x -= t;
  282.     writeChar('.');
  283.     for (int i = output_len - 1; i > 0; i--) {
  284.         x *= 10;
  285.         t = std::min(9, (int)x);
  286.         writeChar('0' + t), x -= t;
  287.     }
  288.     x *= 10;
  289.     t = std::min(9, (int)(x + 0.5));
  290.     writeChar('0' + t);
  291. }
  292.  
  293. signed main(){
  294.     int n, k, l;
  295.     n = readInt();
  296.     k = readInt();
  297.     l = readInt();
  298.  
  299.     vpii left;
  300.     vpii right;
  301.     vi beta;
  302.     vector<double> answer(k, 0);
  303.     int cnt = 0;
  304.     for(int i=0; i<n; i++){
  305.         int a, b;
  306.         char c;
  307.         a=readInt();
  308.         b=readInt();
  309.         c=readChar();
  310.         if(c=='L'){
  311.             beta.pb(cnt);
  312.             left.pb(make_pair(a, b));
  313.         } else{
  314.             cnt++;
  315.             answer[b]+=(l-a);
  316.             right.pb(make_pair(a, b));
  317.         }
  318.     }
  319.     for(int i=0; i<left.size(); i++){
  320.         double last = left[i].first;
  321.         for(int j=beta[i]-1; j>=0; j--){
  322.             answer[left[i].second] += (last-(right[j].first+left[i].first-last))/2.0;
  323.             last = (left[i].first+right[j].first)/2.0;
  324.             left[i].second = (right[j].second+left[i].second)%k;
  325.         }
  326.         answer[left[i].second]+=last;
  327.     }
  328.     for(ld kek:answer)
  329.         writeDouble(kek);
  330.     return 0;
  331. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement