Submission #160629

# Submission time Handle Problem Language Result Execution time Memory
160629 2019-10-29T01:59:52 Z dantoh000 Sterilizing Spray (JOI15_sterilizing) C++14
80 / 100
5000 ms 15640 KB
#include <bits/stdc++.h>
#define int long long
using namespace std;
struct node {
    int s,e,m,v;
    node *l, *r;
    node (int _s, int _e){
        s = _s; e = _e; m = (s+e)/2;
        if (s != e){
            l = new node (s,m);
            r = new node (m+1,e);
        }
    }
    void up(int x, int nv){
        if (s == e) {v = nv; return;}
        if (x > m) r -> up(x,nv);
        if (x <= m) l -> up(x,nv);
        v = l->v + r->v;
    }
    void spray(int x, int y, int k){
        //printf("%lld %lld %lld %lld %lld\n",s,e,x,y,k);
        if (s == e){
            v /= k;
            return;
        }
        else if (s == x && e == y){
            if (v == 0) return;
            l->spray(x,m,k);
            r->spray(m+1,y,k);
            v = l->v + r-> v;
        }
        else{
            if (x > m) r -> spray(x,y,k);
            else if (y <= m) l -> spray(x,y,k);
            else l -> spray(x,m,k), r -> spray(m+1,y,k);
            v = l->v + r->v;
        }
    }
    int sum(int x, int y){
        if (s == x && e == y) return v;
        if (x > m) return r -> sum(x,y);
        if (y <= m) return l -> sum(x,y);
        return l->sum(x,m) + r->sum(m+1,y);
    }
} *root;
main(){
    int n,q,k;
    scanf("%lld%lld%lld",&n,&q,&k);
    root = new node (0,n-1);
    for (int i = 0; i < n; i++){
        int x;
        scanf("%lld",&x);
        root -> up(i,x);
    }
    for (int i = 0; i < q; i++){
        int qu,a,b;
        scanf("%lld%lld%lld",&qu,&a,&b);
        a--; b--;
        if (qu == 1){
            b++;
            root -> up(a,b);
        }
        if (qu == 2){
            root -> spray(a,b,k);
        }
        if (qu == 3){
            printf("%lld\n",root->sum(a,b));
        }
        //for (int i = 0; i < n; i++){
        //    printf("%lld ",root->sum(i,i));
        //}
        //printf("\n");
    }


}

Compilation message

sterilizing.cpp:46:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
 main(){
      ^
sterilizing.cpp: In function 'int main()':
sterilizing.cpp:48:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%lld%lld%lld",&n,&q,&k);
     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:52:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld",&x);
         ~~~~~^~~~~~~~~~~
sterilizing.cpp:57:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%lld%lld%lld",&qu,&a,&b);
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 4 ms 376 KB Output is correct
2 Correct 5 ms 504 KB Output is correct
3 Correct 3 ms 636 KB Output is correct
4 Correct 7 ms 504 KB Output is correct
5 Correct 8 ms 760 KB Output is correct
6 Correct 7 ms 760 KB Output is correct
7 Correct 11 ms 764 KB Output is correct
8 Correct 7 ms 760 KB Output is correct
9 Correct 8 ms 848 KB Output is correct
10 Correct 7 ms 760 KB Output is correct
11 Correct 7 ms 760 KB Output is correct
12 Correct 7 ms 760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 5029 ms 8264 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 32 ms 1656 KB Output is correct
2 Correct 36 ms 6264 KB Output is correct
3 Correct 45 ms 6392 KB Output is correct
4 Correct 97 ms 4776 KB Output is correct
5 Correct 174 ms 14396 KB Output is correct
6 Correct 170 ms 14308 KB Output is correct
7 Execution timed out 5019 ms 13840 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 160 ms 8452 KB Output is correct
2 Correct 189 ms 8800 KB Output is correct
3 Correct 188 ms 7320 KB Output is correct
4 Correct 205 ms 6396 KB Output is correct
5 Correct 268 ms 15608 KB Output is correct
6 Correct 308 ms 15608 KB Output is correct
7 Correct 267 ms 15640 KB Output is correct
8 Correct 351 ms 15608 KB Output is correct
9 Correct 268 ms 15484 KB Output is correct
10 Correct 292 ms 15480 KB Output is correct
11 Correct 224 ms 15452 KB Output is correct
12 Correct 382 ms 15640 KB Output is correct