Submission #375053

# Submission time Handle Problem Language Result Execution time Memory
375053 2021-03-09T01:26:41 Z daniel920712 Examination (JOI19_examination) C++14
20 / 100
198 ms 35948 KB
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>

using namespace std;
struct A
{
    int l,r;
    int nxl,nxr;
    int sum;
}Node[1000005];
int ans[1000005];
vector < pair < int , int > > query[5][200005];
int now=1;
void build(int l,int r,int here)
{
    Node[here].l=l;
    Node[here].r=r;
    Node[here].sum=0;
    if(l==r) return;
    Node[here].nxl=now++;
    Node[here].nxr=now++;
    build(l,(l+r)/2,Node[here].nxl);
    build((l+r)/2+1,r,Node[here].nxr);
}
void cha(int where,int here)
{
    Node[here].sum++;
    if(where==Node[here].l&&where==Node[here].r) return;
    if(where<=(Node[here].l+Node[here].r)/2) cha(where,Node[here].nxl);
    else cha(where,Node[here].nxr);
}
int Find(int l,int r,int here)
{
    if(l==Node[here].l&&r==Node[here].r) return Node[here].sum;
    if(r<=(Node[here].l+Node[here].r)/2) return Find(l,r,Node[here].nxl);
    else if(l>(Node[here].l+Node[here].r)/2) return Find(l,r,Node[here].nxr);
    else return Find(l,(Node[here].l+Node[here].r)/2,Node[here].nxl)+Find((Node[here].l+Node[here].r)/2+1,r,Node[here].nxr);
}
int main()
{
    int N,M,i,j,x,y,z;
    scanf("%d %d",&N,&M);
    for(i=0;i<N;i++)
    {
        scanf("%d %d",&x,&y);
        query[0][x].push_back(make_pair(y,0));
    }
    for(i=0;i<M;i++)
    {
        scanf("%d %d %d",&x,&y,&z);
        query[1][x].push_back(make_pair(y,i));
    }
    build(0,100000,0);
    for(i=100000;i>=0;i--)
    {
        for(auto j:query[0][i]) cha(j.first,0);
        for(auto j:query[1][i]) ans[j.second]=Find(j.first,100000,0);
    }
    for(i=0;i<M;i++) printf("%d\n",ans[i]);
    return 0;
}

Compilation message

examination.cpp: In function 'int main()':
examination.cpp:43:15: warning: unused variable 'j' [-Wunused-variable]
   43 |     int N,M,i,j,x,y,z;
      |               ^
examination.cpp:44:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   44 |     scanf("%d %d",&N,&M);
      |     ~~~~~^~~~~~~~~~~~~~~
examination.cpp:47:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   47 |         scanf("%d %d",&x,&y);
      |         ~~~~~^~~~~~~~~~~~~~~
examination.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   52 |         scanf("%d %d %d",&x,&y,&z);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 27776 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 183 ms 35432 KB Output is correct
2 Correct 198 ms 35436 KB Output is correct
3 Correct 180 ms 35436 KB Output is correct
4 Correct 140 ms 34924 KB Output is correct
5 Correct 124 ms 32788 KB Output is correct
6 Correct 96 ms 32236 KB Output is correct
7 Correct 164 ms 34668 KB Output is correct
8 Correct 169 ms 35436 KB Output is correct
9 Correct 158 ms 34516 KB Output is correct
10 Correct 125 ms 32352 KB Output is correct
11 Correct 134 ms 34540 KB Output is correct
12 Correct 96 ms 31200 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 183 ms 35432 KB Output is correct
2 Correct 198 ms 35436 KB Output is correct
3 Correct 180 ms 35436 KB Output is correct
4 Correct 140 ms 34924 KB Output is correct
5 Correct 124 ms 32788 KB Output is correct
6 Correct 96 ms 32236 KB Output is correct
7 Correct 164 ms 34668 KB Output is correct
8 Correct 169 ms 35436 KB Output is correct
9 Correct 158 ms 34516 KB Output is correct
10 Correct 125 ms 32352 KB Output is correct
11 Correct 134 ms 34540 KB Output is correct
12 Correct 96 ms 31200 KB Output is correct
13 Incorrect 183 ms 35948 KB Output isn't correct
14 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 20 ms 27776 KB Output isn't correct
2 Halted 0 ms 0 KB -