Submission #25076

# Submission time Handle Problem Language Result Execution time Memory
25076 2017-06-20T06:08:18 Z 윤교준(#1055) Sterilizing Spray (JOI15_sterilizing) C++
Compilation error
0 ms 0 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, int 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;
        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);
    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

In file included from /usr/include/c++/5/unordered_map:35:0,
                 from sterilizing.cpp:13:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \
  ^
sterilizing.cpp: In function 'int main()':
sterilizing.cpp:72: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:74: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:77: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);
                                       ^