답안 #25084

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
25084 2017-06-20T06:18:25 Z 윤교준(#1055) Sterilizing Spray (JOI15_sterilizing) C++11
10 / 100
179 ms 8296 KB
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <bitset>
#include <string>
#define pb push_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define INF (1100000099)
#define INFLL (1100000000000000099ll)
#define MAXN (100005)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
struct LAZYSEG {
    ll dt[MAXN<<2], lz[MAXN<<2];
    void init() { fill(lz, lz+(MAXN<<2), 1); }
    void uplz(int idx, ll R) { lz[idx] *= R; if(INF < lz[idx]) lz[idx] = INF; }
    void prop(int idx, int S, int E) {
        if(1 == lz[idx]) return;
        dt[idx] /= lz[idx];
        if(S != E) { uplz(idx*2, lz[idx]); uplz(idx*2+1, lz[idx]); }
        lz[idx] = 1;
    }
    void opSeg(int idx, int S, int E, int P, int Q, int R) {
        prop(idx, S, E);
        if(E < P || Q < S) return;
        if(P <= S && E <= Q) { uplz(idx, R); prop(idx, S, E); return; }
        const int M = (S+E)/2;
        opSeg(idx*2, S, M, P, Q, R); opSeg(idx*2+1, M+1, E, P, Q, R);
        dt[idx] = dt[idx*2] + dt[idx*2+1];
    }
    void inSeg(int idx, int S, int E, int X, int R) {
        prop(idx, S, E); if(E < X || X < S) return;
        if(S == E) { dt[idx] = R; return; }
        const int M = (S+E)/2;
        inSeg(idx*2, S, M, X, R); inSeg(idx*2+1, M+1, E, X, R);
        dt[idx] = dt[idx*2] + dt[idx*2+1];
    }
    ll getSeg(int idx, int S, int E, int P, int Q) {
        prop(idx, S, E);
        if(Q < P || E < P || Q < S) return 0;
        if(P <= S && E <= Q) return dt[idx];
        const int M = (S+E)/2;
        ll ret = getSeg(idx*2, S, M, P, Q) + getSeg(idx*2+1, M+1, E, P, Q);
        dt[idx] = dt[idx*2] + dt[idx*2+1];
        return ret;
    }
};

LAZYSEG ST;
int N, Q, K;

int main() {
    ST.init();
    scanf("%d%d%d", &N, &Q, &K);
    for(int i = 1, c; i <= N; i++) {
        scanf("%d", &c); ST.inSeg(1, 1, N, i, c);
    }
    for(int type, a, b; Q--;) {
        scanf("%d%d%d", &type, &a, &b);
        if(1 == type) ST.inSeg(1, 1, N, a, b);
        else if(2 == type) ST.opSeg(1, 1, N, a, b, K);
        else printf("%lld\n", ST.getSeg(1, 1, N, a, b));
    }
    return 0;
}

Compilation message

sterilizing.cpp: In function 'int main()':
sterilizing.cpp:74:32: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d%d%d", &N, &Q, &K);
                                ^
sterilizing.cpp:76:24: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d", &c); ST.inSeg(1, 1, N, i, c);
                        ^
sterilizing.cpp:79:39: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d%d%d", &type, &a, &b);
                                       ^
# 결과 실행 시간 메모리 Grader output
1 Incorrect 6 ms 8296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 96 ms 8296 KB Output is correct
2 Correct 89 ms 8296 KB Output is correct
3 Correct 103 ms 8296 KB Output is correct
4 Correct 139 ms 8296 KB Output is correct
5 Correct 166 ms 8296 KB Output is correct
6 Correct 143 ms 8296 KB Output is correct
7 Correct 176 ms 8296 KB Output is correct
8 Correct 179 ms 8296 KB Output is correct
9 Correct 159 ms 8296 KB Output is correct
10 Correct 136 ms 8296 KB Output is correct
11 Correct 103 ms 8296 KB Output is correct
12 Correct 116 ms 8296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 56 ms 8296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 156 ms 8296 KB Output isn't correct
2 Halted 0 ms 0 KB -