daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Dec 16th, 2018 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include<bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. using ll = long long;
  6. using ld = long double;
  7. using pii = pair<int, int>;
  8. using pdd = pair<ld, ld>;
  9.  
  10. int __intend = 0;
  11. void nextIntend(){__intend++;}
  12. void prevIntend(){__intend--;}
  13. string getIntend(){
  14.     string r;
  15.     for (int i = 0; i < __intend; ++i){
  16.         r += '\t';
  17.     }
  18.     return r;
  19. }
  20.  
  21. template<typename T>
  22. void print(const char s[], bool intend, T & v){
  23.     if (intend) cout << getIntend();
  24.     cout << s << " = " << v << endl;
  25. }
  26.  
  27. template<typename T, typename... TA>
  28. void print(const char s[], bool intend, T & v, TA&... args){
  29.     if (intend) cout << getIntend();
  30.     while(*s != ','){
  31.         if (*s != ' ') cout << *s;
  32.         s++;
  33.     }
  34.     while(*s == ',' || *s == ' ') s++;
  35.     cout << " = " << v << " | ";
  36.     print(s, false, args...);
  37. }
  38.  
  39. #if _DEBUG
  40. #define de if (1)
  41. #define dbg(...) print(#__VA_ARGS__, 1, __VA_ARGS__)
  42. #else
  43. #define de if (0)
  44. #define dbg(...)
  45. #endif
  46.  
  47.  
  48.  
  49. #define ho(x) #x << " = " << x << " | "
  50. #define gint getIntend
  51. #define nint nextIntend
  52. #define pint prevIntend
  53.  
  54.  
  55. void solve(){
  56.     de cout << "Started app" << endl;
  57.     de cout.flush();
  58.     int n, w, l;
  59.     cin >> n >> w >> l;
  60.     de cout << "Readed n w l" << endl;
  61.     de cout << ho(n) << ho(w) << ho(l) << endl;
  62.     multiset<int> curBatary;
  63.     curBatary.insert(0);
  64.     curBatary.insert(l);
  65.     vector<vector<int>> startBatary(w + 2);
  66.     vector<vector<int>> endBatary(w + 2);
  67.     vector<int> mxLen(l);
  68.     mxLen[0] = l;
  69.     priority_queue<pii, vector<pii>, less<pii>> curMax;
  70.     curMax.push({l, 0});
  71.     for (int i = 0; i < n; ++i){
  72.         int x, a, b;
  73.         cin >> x >> a >> b;
  74.         b++; // to [a, b)
  75.         startBatary[a].push_back(x);
  76.         endBatary[b].push_back(x);
  77.     }
  78.     de cout << "Readed batary" << endl;
  79.     for (int i = 0; i <= w; ++i){
  80.         de cout << gint() << ho(i) << endl;
  81.         nint();
  82.         for (int x : endBatary[i]){
  83.             de cout << gint() << "delete " << ho(x) << endl;
  84.             auto it = curBatary.erase(curBatary.find(x));
  85.             int rx = *it;
  86.             int lx = *--it;
  87.             if (rx - lx){
  88.                 mxLen[lx] = rx - lx;
  89.                 de cout << gint() << "on " << lx << " put " << mxLen[lx] << endl;
  90.                 curMax.push({mxLen[lx], lx});
  91.             }
  92.         }
  93.         for (int x : startBatary[i]){
  94.             de cout << gint() << "add " << ho(x) << endl;
  95.             auto it = curBatary.insert(x);
  96.             int lx = *--it;
  97.             int rx = *++++it;
  98.             if (x - lx){
  99.                 mxLen[lx] = x - lx;
  100.                 de cout << gint() << "on " << lx << " put " << mxLen[lx] << endl;
  101.                 curMax.push({mxLen[lx], lx});
  102.             }
  103.             if (rx - x){
  104.                 mxLen[x] = rx - x;
  105.                 de cout << gint() << "on " << x << " put " << mxLen[x] << endl;
  106.                 curMax.push({mxLen[x], x});
  107.             }
  108.         }
  109.         while(curMax.size() && mxLen[curMax.top().second] != curMax.top().first){
  110.             de cout << gint() << "false " << ho(curMax.top().first) << ho(curMax.top().second) << endl;
  111.             curMax.pop();
  112.         }
  113.         pint();
  114.         cout << curMax.top().first << endl;
  115.     }
  116. }
  117.  
  118. const bool fastIO = true;
  119. const bool withTest = false;
  120. const bool fileIO = false;
  121. #define file "file"
  122.  
  123. int main(){
  124.     #if _STRESS
  125.         const bool fileIO = false;
  126.     #endif
  127.     #if !_DEBUG
  128.         if (fileIO){
  129.             freopen(file".in", "r", stdin);
  130.             freopen(file".out", "w", stdout);
  131.         }
  132.     #endif
  133.     if (fastIO){
  134.         cin.tie(0);
  135.         cout.tie(0);
  136.         ios_base::sync_with_stdio(0);
  137.     }
  138.     if (withTest){
  139.         int t;
  140.         cin >> t;
  141.         while(t--) solve();
  142.     }
  143.     else solve();
  144. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top