Submission #25090

# Submission time Handle Problem Language Result Execution time Memory
25090 2017-06-20T06:27:29 Z 윤교준(#1055) Sterilizing Spray (JOI15_sterilizing) C++11
10 / 100
3899 ms 8272 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) {
        //printf("prop %d %d %d : %lld\n", idx, S, E, lz[idx]);
        if(1 == lz[idx]) return;
        while(1) puts("?");
        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) {
        //printf("opSeg %d %d %d %d %d %d\n", idx, S, E, P, Q, 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;
        return getSeg(idx*2, S, M, P, Q) + getSeg(idx*2+1, M+1, E, P, Q);
    }
};

LAZYSEG ST;
int N, Q, K;

int main() {
    ST.init();
    scanf("%d%d%d", &N, &Q, &K);
    if(1 != K) while(1) puts("?");
    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:75: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:78: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:81: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);
                                       ^
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 0 KB -1: Interrupted system call
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 119 ms 8272 KB Output is correct
2 Correct 106 ms 8272 KB Output is correct
3 Correct 109 ms 8272 KB Output is correct
4 Correct 159 ms 8272 KB Output is correct
5 Correct 119 ms 8272 KB Output is correct
6 Correct 169 ms 8272 KB Output is correct
7 Correct 173 ms 8272 KB Output is correct
8 Correct 163 ms 8272 KB Output is correct
9 Correct 146 ms 8272 KB Output is correct
10 Correct 126 ms 8272 KB Output is correct
11 Correct 153 ms 8272 KB Output is correct
12 Correct 153 ms 8272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 3899 ms 8272 KB Execution timed out (wall clock limit exceeded)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 0 ms 0 KB -1: Interrupted system call
2 Halted 0 ms 0 KB -