Submission #945077

# Submission time Handle Problem Language Result Execution time Memory
945077 2024-03-13T11:31:01 Z JakobZorz Examination (JOI19_examination) C++17
0 / 100
3000 ms 12748 KB
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<limits.h>
#include<math.h>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<iomanip>
#include<cstring>
#include<random>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

struct Obj{
    int a,b,c;
    int res=0;
    bool is_q=false;
};

bool cmp1(Obj*a,Obj*b){
    if(a->c==b->c&&a->b==b->b)
        return a->a<b->a;
    if(a->c==b->c)
        return a->b<b->b;
    return a->c<b->c;
}

void proc(vector<Obj*>vals,vector<Obj*>qrs){
    for(auto i:qrs){
        for(auto j:vals){
            if(j->a>=i->a&&j->b>=i->b)
                i->res++;
        }
    }
}

void dc(vector<Obj*>arr){
    if(arr.empty())
        return;
    int n=(int)arr.size();
    vector<Obj*>qrs,vals;
    vector<Obj*>arr1,arr2;
    for(int i=n/2;i<n;i++){
        arr2.push_back(arr[i]);
        if(!arr[i]->is_q)
            vals.push_back(arr[i]);
    }
    for(int i=0;i<n/2;i++){
        arr1.push_back(arr[i]);
        if(arr[i]->is_q)
            qrs.push_back(arr[i]);
    }
    proc(vals,qrs);
    if(n>1){
        dc(arr1);
        dc(arr2);
    }
}

void solve(){
    int n,q;
    cin>>n>>q;
    vector<Obj>arr(n);
    for(Obj&i:arr){
        cin>>i.a>>i.b;
        i.c=i.a+i.b;
    }
    vector<Obj>qrs(q);
    for(Obj&i:qrs){
        cin>>i.a>>i.b>>i.c;
        i.is_q=true;
    }
    vector<Obj*>all;
    for(Obj&i:arr)
        all.push_back(&i);
    for(Obj&i:qrs)
        all.push_back(&i);
    sort(all.begin(),all.end(),cmp1);
    dc(all);
    for(auto i:qrs)
        cout<<i.res<<"\n";
}

int main(){
    ios::sync_with_stdio(false);cout.tie(NULL);cin.tie(NULL);
    //freopen("/Users/jakob/cp_testing/test.txt","r",stdin);freopen("output.out","w",stdout);
    int t=1;//cin>>t;
    while(t--)solve();
    return 0;
}


/*

5 4
35 100
70 70
45 15
80 40
20 95
20 50 120
10 10 100
60 60 80
0 100 100
 
 */

# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 20 ms 768 KB Output is correct
8 Correct 20 ms 860 KB Output is correct
9 Correct 19 ms 856 KB Output is correct
10 Correct 13 ms 916 KB Output is correct
11 Correct 17 ms 860 KB Output is correct
12 Incorrect 10 ms 860 KB Output isn't correct
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3075 ms 12748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3075 ms 12748 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 20 ms 768 KB Output is correct
8 Correct 20 ms 860 KB Output is correct
9 Correct 19 ms 856 KB Output is correct
10 Correct 13 ms 916 KB Output is correct
11 Correct 17 ms 860 KB Output is correct
12 Incorrect 10 ms 860 KB Output isn't correct
13 Halted 0 ms 0 KB -