Submission #557822

# Submission time Handle Problem Language Result Execution time Memory
557822 2022-05-06T05:43:50 Z hibiki Examination (JOI19_examination) C++11
0 / 100
523 ms 1048576 KB
#include<bits/stdc++.h>
using namespace std;

#define PB push_back
#define F first
#define S second

const int MX_VAL = 1e9+7;

class FenwickTree
{
private:
    int N;
    vector<int> arr;
public:
    FenwickTree() {}
    FenwickTree(int n)
    {
        N=n;
        arr.resize(n);
    }

    void update(int idx,int val)
    {
        idx++;
        while(idx<N)
        {
            arr[idx] += val;
            idx += idx & -idx;
        }
        return ;
    }

    int query(int idx)
    {
        idx++;
        int ret=0;
        while(idx>0)
        {
            ret += arr[idx];
            idx -= idx & -idx;
        }
        return ret;
    }
};

int n,q;
int sA[100005],sB[100005];
int qA[100005],qB[100005],qC[100005],ans[100005];
vector<pair<int,pair<int,int> > > poi;

int main()
{
    scanf("%d %d",&n,&q);
    for(int i=0;i<n;i++)
    {
        scanf("%d %d",&sA[i],&sB[i]);
        poi.PB({ -(sA[i]+sB[i]) , {0,i} });
    }
    for(int i=0;i<q;i++)
    {
        scanf("%d %d %d",&qA[i],&qB[i],&qC[i]);
        poi.PB({ -(max(qA[i]+qB[i],qC[i])) , {1,i} });
    }

    sort(poi.begin(),poi.end());

    int all=0;
    FenwickTree FwA(MX_VAL),FwB(MX_VAL);
    for(int i=0;i<poi.size();i++)
    {
        int ty=poi[i].S.F;
        int idx=poi[i].S.S;
        if(!ty)
        {
            all++;
            FwA.update(sA[idx],1);
            FwB.update(sB[idx],1);
        }
        else
        {
            ans[idx] = all - FwA.query(max(0,qA[idx]-1)) - FwB.query(max(0,qB[idx]-1));
        }
    }

    for(int i=0;i<q;i++)
        printf("%d\n",ans[i]);

    return 0;
}

Compilation message

examination.cpp: In function 'int main()':
examination.cpp:70:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, std::pair<int, int> > >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     for(int i=0;i<poi.size();i++)
      |                 ~^~~~~~~~~~~
examination.cpp:54:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   54 |     scanf("%d %d",&n,&q);
      |     ~~~~~^~~~~~~~~~~~~~~
examination.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   57 |         scanf("%d %d",&sA[i],&sB[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
examination.cpp:62:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         scanf("%d %d %d",&qA[i],&qB[i],&qC[i]);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Runtime error 523 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 498 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 498 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 523 ms 1048576 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -