Submission #715174

# Submission time Handle Problem Language Result Execution time Memory
715174 2023-03-26T07:09:30 Z Huseyn123 Examination (JOI19_examination) C++17
0 / 100
3000 ms 9532 KB
#include <bits/stdc++.h>
#define MAX 200001
#define INF LLONG_MAX
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define ins insert
#define ff first
#define ss second
#define gett(x,m) get<m>(x)
#define all(a) a.begin(),a.end()
#define lb(a,b) lower_bound(all(a),b)
#define ub(a,b) upper_bound(all(a),b)
#define sortv(a) sort(all(a))
#define sorta(a,sz) sort(a,a+sz)
#define inputar(a,b){\
    for(int i=0;i<b;i++){\
        cin >> a[i];\
    }\
}
#define inputvec(a,b){\
    for(int i=0;i<b;i++){\
        ll num;\
        cin >> num;\
        a.pb(num);\
    }\
}
#define outputar(a,b){\
    for(int i=0;i<b;i++){\
        cout << a[i] << " ";\
    }\
    cout << "\n";\
}
#define outputvec(a){\
    for(auto x:a){\
        cout << x << " ";\
    }\
    cout << "\n";\
}
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef tuple<ll,ll,ll> tll;
typedef pair<ll,ll> pll;
typedef double db;
typedef long double ldb;
inline void USACO(string filename){
  freopen((filename+".in").c_str(),"r",stdin);
  freopen((filename+".out").c_str(),"w",stdout);
}
ll n,q,t=1,m,n2,m2,k,cnt=0,a[MAX],b[MAX],d2[MAX],x,y,z,x2,y2,z2,res1=0,cnt1,cnt2,cnt3;
struct segtree2{
    int size;
    vector<pll> tree;
    void init(int n){
        size=1;
        while(size<n){
            size*=2;
        }
        tree.assign(2*size,{-1,-1});
    }
    void upd(int cnt,int l,int r,int v,int x,int lx,int rx){
        if(lx>=r || rx<=l){
            return;
        }
        if(lx>=l && rx<=r){
            tree[x]=mp(v,cnt);
            return;
        }
        int m=(lx+rx)/2;
        upd(cnt,l,r,v,2*x+1,lx,m);
        upd(cnt,l,r,v,2*x+2,m,rx);
    }
    void upd(int cnt,int l,int r,int v){
        upd(cnt,l,r,v,0,0,size);
    }
    pll get(int i,int x,int lx,int rx){
        if(rx-lx==1){
            return tree[x];
        }
        int m=(lx+rx)/2;
        pll res;
        if(i<m){
            res=get(i,2*x+1,lx,m);
        }
        else{
            res=get(i,2*x+2,m,rx);
        }
        if(tree[x].ss>res.ss){
            res=tree[x];
        }
        return res;
    }
    ll get(int i){
        return get(i,0,0,size).ff;
    }
};
ll sum[MAX];
void update(ll x,ll v){
    while(x<=n){
        sum[x]+=v;
        x+=x&-x;
    }
}
ll get_sum(ll x){
    ll res=0;
    while(x>=1){
        res+=sum[x];
        x-=x&-x;
    }
    return res;
}
struct query{
    ll x,y,z,id;
};
bool comp(query a,query b){
    return a.x>b.x;
}
vector<query> queries;
void solve(){
    cin >> n >> m;
    queries.resize(m);
    vector<pll> c;
    for(int i=0;i<n;i++){
        cin >> x >> y;
        x++;
        y++;
        c.pb(mp(x,y));
    }
    for(int i=0;i<m;i++){
        queries[i].id=i;
        cin >> queries[i].x >> queries[i].y >> queries[i].z;
        queries[i].x++;
        queries[i].y++;
        queries[i].z+=2;
    }
    sort(all(queries),comp);
    sortv(c);
    reverse(all(c));
    ll j=0;
    set<ll> d;
    for(int i=0;i<m;i++){
        while(j<n && c[j].ff>=queries[i].x){
            d.ins(c[j].ss);
            j++;
        }
        ll h=distance(d.upper_bound(queries[i].y),d.end());
        b[queries[i].id]=h;
    }
    for(int i=0;i<m;i++){
        cout << b[i] << "\n";
    }
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    //USACO("poetry");
    //cin >> t;
    ll cnt1=1;
    while(t--){
        solve();
        cnt1++;
    }
}
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
ifstream fin("template.in");
ofstream fout("template.out");
*/
/*
freopen("input.txt","r",stdin);
freopen("output.txt","w",stdout);
ifstream fin("template.in");
ofstream fout("template.out");
*/
/*
ll b[51][51];
b[0][0] = 1;
    for (int n = 1; n <= 50; ++n){
        b[n][0] = b[n][n] = 1;
        for (int k = 1; k < n; ++k)
            b[n][k] = b[n - 1][k - 1] + b[n - 1][k];
    }
*/
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3046 ms 9532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3046 ms 9532 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -