Submission #964254

# Submission time Handle Problem Language Result Execution time Memory
964254 2024-04-16T13:41:20 Z Unforgettablepl Examination (JOI19_examination) C++17
0 / 100
3000 ms 178068 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long

unordered_map<int,int> tree;

int mak(int a,int b){
    return (a<<32)|b;
}

int get(int x,int y){
    int ans = 0;
    while(x){
        int tempy = y;
        while(tempy){
            if(tree.count(mak(x,tempy)))ans+=tree[mak(x,tempy)];
            tempy-=tempy&-tempy;
        }
        x-=x&-x;
    }
    return ans;
}

void add(int x,int y){
    while(x<=100001){
        int tempy = y;
        while(tempy<=100001){
            tree[mak(x,tempy)]++;
            tempy+=tempy&-tempy;
        }
        x+=x&-x;
    }
}

int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,q;
    cin >> n >> q;
    for(int i=1;i<=n;i++){
        int x,y;cin>>x>>y;
        x = 100001-x;
        y = 100001-y;
        add(x,y);
    }
    for(int i=1;i<=q;i++){
        int a,b,c;cin>>a>>b>>c;
        a = 100001-a;
        b = 100001-b;
        cout << get(a,b) << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3048 ms 178068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3048 ms 178068 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -