Advertisement
Guest User

Untitled

a guest
Sep 21st, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define pb_ push_back
  4. #define eb_ emplace_back
  5. #define mp_ make_pair
  6. //#define endl '\n'
  7. typedef long long ll;
  8. typedef unsigned long long ull;
  9. typedef pair<long,long> pll;
  10. typedef pair<int,int> pii;
  11.  
  12. const int ML = 1e3+5;
  13. int L, T,BIT[3*ML][3*ML];
  14. bool seats[3*ML][3*ML];
  15. ll sum(int r, int c){
  16.    ll ret = 0;
  17.    for(int i = r;i>0;i-=i&-i){
  18.        for(int j = c; j>0; j-=j&-j){
  19.            ret+=BIT[i][j];
  20.        }
  21.    }
  22.    return ret;
  23. }
  24.  
  25. void update(int r, int c, int delta){
  26.     for(int i = r; i < 3*ML; i|=i+1){
  27.         for(int j = c; j < 3*ML; j|=j+1){
  28.             BIT[r][c]+=delta;
  29.         }
  30.     }
  31. }
  32.  
  33. int main(){
  34.     cin.tie(0),cout.tie(0),ios::sync_with_stdio(0);
  35.     cin>>L>>T;
  36.     char c;
  37.     for(int i = 0,a,b; i  < T; i++){
  38.        cin>>c>>a>>b;
  39.        // we want to convert from diamond to square
  40.        if(c=='E'){
  41.            seats[b+a+ML][b-a+ML]=1;
  42.            update(b+a+ML,b-a+ML,1);
  43.        }
  44.        else if(c=='L'){
  45.            seats[b+a+ML][b-a+ML]=0;
  46.            update(b+a+ML,b-a+ML,-1);
  47.        }
  48.        else{
  49.            sum(b-a,)
  50.        }
  51.     }
  52.        
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement