Submission #620327

# Submission time Handle Problem Language Result Execution time Memory
620327 2022-08-03T04:50:40 Z 반딧불(#8518) Sterilizing Spray (JOI15_sterilizing) C++17
10 / 100
62 ms 4784 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

struct segTree{

};

int n, q;
ll k;
ll arr[100002];

void solve_k1();

int main(){
    scanf("%d %d %d", &n, &q, &k);
    for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
    if(k==1) solve_k1();
}

struct Fenwick{
    int n;
    ll tree[100002];

    void init(int _n){
        n=_n;
        for(int i=1; i<=n; i++) tree[i] = 0;
    }

    void add(int x, ll y){
        while(x<=n){
            tree[x] += y;
            x += x&-x;
        }
    }

    ll sum(int x){
        ll ret = 0;
        while(x){
            ret += tree[x];
            x-=x&-x;
        }
        return ret;
    }

    ll sum(int l, int r){
        return sum(r) - sum(l-1);
    }
} fenwick;

void solve_k1(){
    fenwick.init(n);
    for(int i=1; i<=n; i++) fenwick.add(i, arr[i]);
    while(q--){
        int a, b, c;
        scanf("%d %d %d", &a, &b, &c);
        if(a==1){
            fenwick.add(b, c-arr[b]);
            arr[b]=c;
        }
        else if(a==3){
            printf("%lld\n", fenwick.sum(b, c));
        }
    }
    exit(0);
}

Compilation message

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:18:19: warning: format '%d' expects argument of type 'int*', but argument 4 has type 'll*' {aka 'long long int*'} [-Wformat=]
   18 |     scanf("%d %d %d", &n, &q, &k);
      |                  ~^           ~~
      |                   |           |
      |                   int*        ll* {aka long long int*}
      |                  %lld
sterilizing.cpp:18:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   18 |     scanf("%d %d %d", &n, &q, &k);
      |     ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
sterilizing.cpp:19:34: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   19 |     for(int i=1; i<=n; i++) scanf("%lld", &arr[i]);
      |                             ~~~~~^~~~~~~~~~~~~~~~~
sterilizing.cpp: In function 'void solve_k1()':
sterilizing.cpp:58:14: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
   58 |         scanf("%d %d %d", &a, &b, &c);
      |         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 43 ms 3344 KB Output is correct
2 Correct 35 ms 2788 KB Output is correct
3 Correct 36 ms 3472 KB Output is correct
4 Correct 49 ms 4348 KB Output is correct
5 Correct 62 ms 4768 KB Output is correct
6 Correct 56 ms 4784 KB Output is correct
7 Correct 55 ms 4716 KB Output is correct
8 Correct 44 ms 4704 KB Output is correct
9 Correct 49 ms 4600 KB Output is correct
10 Correct 43 ms 4628 KB Output is correct
11 Correct 61 ms 4644 KB Output is correct
12 Correct 46 ms 4568 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 448 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 6 ms 1364 KB Output isn't correct
2 Halted 0 ms 0 KB -