Submission #421787

# Submission time Handle Problem Language Result Execution time Memory
421787 2021-06-09T12:02:26 Z tqbfjotld Food Court (JOI21_foodcourt) C++14
21 / 100
710 ms 51908 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long


struct node{
    int s,e;
    int lazymin,lazych;
    int v;
    node *l,*r;
    node (int _s, int _e){
        s = _s; e = _e;
        lazymin = 0; lazych = 0;
        v = 0;
        if (s!=e){
            l = new node(s,(s+e)/2);
            r = new node((s+e)/2+1,e);
        }
    }
    void proc(){
        if (lazymin==0 && lazych==0) return;
        if (s!=e){
            l->lazymin = min(l->lazymin,l->lazych+lazymin);
            l->lazych += lazych;
            r->lazymin = min(r->lazymin,r->lazych+lazymin);
            r->lazych += lazych;
        }
        if (s==e){
            v += lazymin;
            v = max(v,0LL);
            v -= lazymin;
            v += lazych;
        }
        lazymin = 0;
        lazych = 0;
    }
    void inc(int a, int b, int val){
        proc();
        if (a<=s && e<=b){
            lazych += val;
            proc();
            return;
        }
        else if (b<=(s+e)/2){
            l->inc(a,b,val);
        }
        else if (a>(s+e)/2){
            r->inc(a,b,val);
        }
        else{
            l->inc(a,b,val);
            r->inc(a,b,val);
        }
        l->proc();
        r->proc();
    }
    void dec(int a, int b, int val){
        proc();
        if (a<=s && e<=b){
            lazych -= val;
            lazymin = min(lazymin,lazych);
            proc();
            return;
        }
        else if (b<=(s+e)/2){
            l->dec(a,b,val);
        }
        else if (a>(s+e)/2){
            r->dec(a,b,val);
        }
        else{
            l->dec(a,b,val);
            r->dec(a,b,val);
        }
        l->proc(); r->proc();
    }
    int qu(int pos){
        proc();
        if (s==e) return v;
        if (pos>(s+e)/2)return r->qu(pos);
        else return l->qu(pos);
    }
}*root;

struct q_dat{
    int l,r;
    int t,k;
    q_dat(){
        l = 0; r = 0; t = 0; k = 0;
    }
    q_dat(int _l, int _r, int _t, int _k){
        l = _l; r = _r; t = _t; k = _k;
    }
};
vector<q_dat> query1;
int groupnum[250005];
vector<q_dat> query2;
vector<pair<pair<int,int>,int> > query3;

main(){
    int n,m,q;
    scanf("%lld%lld%lld",&n,&m,&q);
    root = new node(1,n);
    for (int x = 0; x<q; x++){
        int a;
        scanf("%lld",&a);
        if (a==1){
            int b,c,d,e;
            scanf("%lld%lld%lld%lld",&b,&c,&d,&e);
            groupnum[x] = d;
            query1.push_back(q_dat(b,c,x,e));
            root->inc(b,c,e);
        }
        else if (a==2){
            int b,c,d;
            scanf("%lld%lld%lld",&b,&c,&d);
            query2.push_back(q_dat(b,c,x,d));
            root->dec(b,c,d);
        }
        else if (a==3){
            int b,c;
            scanf("%lld%lld",&b,&c);
            query3.push_back({{b,c},x});
            int num = root->qu(b);
           // printf("%lld has %lld\n",b,num);
            if (num>=c){
                printf("1\n");
            }
            else{
                printf("0\n");
            }
        }
    }

}

Compilation message

foodcourt.cpp:100:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  100 | main(){
      | ^~~~
foodcourt.cpp: In function 'int main()':
foodcourt.cpp:102:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  102 |     scanf("%lld%lld%lld",&n,&m,&q);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:106:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  106 |         scanf("%lld",&a);
      |         ~~~~~^~~~~~~~~~~
foodcourt.cpp:109:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  109 |             scanf("%lld%lld%lld%lld",&b,&c,&d,&e);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:116:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  116 |             scanf("%lld%lld%lld",&b,&c,&d);
      |             ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
foodcourt.cpp:122:18: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
  122 |             scanf("%lld%lld",&b,&c);
      |             ~~~~~^~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 108 ms 10992 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 519 ms 38172 KB Output is correct
2 Correct 446 ms 35824 KB Output is correct
3 Correct 609 ms 46868 KB Output is correct
4 Correct 444 ms 43256 KB Output is correct
5 Correct 501 ms 36848 KB Output is correct
6 Correct 633 ms 47332 KB Output is correct
7 Correct 127 ms 13792 KB Output is correct
8 Correct 113 ms 14056 KB Output is correct
9 Correct 525 ms 46952 KB Output is correct
10 Correct 541 ms 46908 KB Output is correct
11 Correct 597 ms 50812 KB Output is correct
12 Correct 614 ms 51908 KB Output is correct
13 Correct 625 ms 47052 KB Output is correct
14 Correct 609 ms 47880 KB Output is correct
15 Correct 677 ms 47324 KB Output is correct
16 Correct 613 ms 47128 KB Output is correct
17 Correct 622 ms 47316 KB Output is correct
18 Correct 674 ms 48652 KB Output is correct
19 Correct 650 ms 47184 KB Output is correct
20 Correct 635 ms 47672 KB Output is correct
21 Correct 653 ms 47200 KB Output is correct
22 Correct 673 ms 47420 KB Output is correct
23 Correct 642 ms 47172 KB Output is correct
24 Correct 710 ms 47232 KB Output is correct
25 Correct 357 ms 39260 KB Output is correct
26 Correct 429 ms 46712 KB Output is correct
27 Correct 487 ms 49324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 120 ms 10268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 588 KB Output isn't correct
2 Halted 0 ms 0 KB -