Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define pb_ push_back
- #define eb_ emplace_back
- #define mp_ make_pair
- //#define endl '\n'
- typedef long long ll;
- typedef unsigned long long ull;
- typedef pair<long,long> pll;
- typedef pair<int,int> pii;
- const int ML = 1e3+5;
- int L, T,BIT[3*ML][3*ML];
- bool seats[3*ML][3*ML];
- ll sum(int r, int c){
- ll ret = 0;
- for(int i = r;i>0;i-=i&-i){
- for(int j = c; j>0; j-=j&-j){
- ret+=BIT[i][j];
- }
- }
- return ret;
- }
- void update(int r, int c, int delta){
- for(int i = r; i < 3*ML; i|=i+1){
- for(int j = c; j < 3*ML; j|=j+1){
- BIT[r][c]+=delta;
- }
- }
- }
- int main(){
- cin.tie(0),cout.tie(0),ios::sync_with_stdio(0);
- cin>>L>>T;
- char c;
- for(int i = 0,a,b; i < T; i++){
- cin>>c>>a>>b;
- // we want to convert from diamond to square
- if(c=='E'){
- seats[b+a+ML][b-a+ML]=1;
- update(b+a+ML,b-a+ML,1);
- }
- else if(c=='L'){
- seats[b+a+ML][b-a+ML]=0;
- update(b+a+ML,b-a+ML,-1);
- }
- else{
- sum(b-a,)
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement