답안 #197586

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
197586 2020-01-21T20:23:54 Z stefdasca Watering can (POI13_kon) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
// #include "koninc.h"
using namespace std;

const int MAXN = 300001, rad = 1002;

int N, K, v[MAXN+5];

int buk[MAXN+5], L[MAXN+5], R[MAXN+5], ad[MAXN+5], nrbuk, aans[MAXN+5];

short ans[102][MAXN+5];

void proc(int bk)
{
    for(int j = L[bk]; j <= R[bk]; ++j)
    {
        if(v[j] >= K)
            ans[bk][0] = 0;
        else
            if(K - v[j] <= 300000)
                ans[bk][K - v[j]] = 0;
    }
    for(int j = L[bk]; j <= R[bk]; ++j)
    {
        v[j] += ad[bk];
        if(v[j] >= K)
            ans[bk][0]++;
        else
            if(K - v[j] <= 300000)
                ans[bk][K - v[j]]++;
    }
    ad[bk] = 0;
    aans[bk] = ans[bk][0];
}

void inicjuj(int n, int k, int *D)
{
    N = n, K = k;
    for(int i = 0; i < n; ++i)
        v[i] = D[i];
    for(int i = 0; i < n; ++i)
    {
        if(i % rad == 0)
            ++nrbuk, L[nrbuk] = i;
        R[nrbuk] = i;
        assert(nrbuk <= 101);
        buk[i] = nrbuk;
    }
    for(int i = 0; i <= nrbuk; ++i)
        proc(i);
}

void podlej(int a, int b)
{
    int fini = R[buk[a]];
    while(a <= b && a <= fini)
    {
        ++v[a];
        ++a;
    }
    proc(buk[a]);
    while(a < N && R[buk[a]] <= b)
    {
        ++ad[buk[a]];
        aans[buk[a]] = aans[buk[a]] + ans[buk[a]][ad[buk[a]]];
        a = R[buk[a]] + 1;
    }
    if(a <= b)
    {
        fini = R[buk[a]];
        while(a <= b && a <= fini)
        {
            ++v[a];
            ++a;
        }
        proc(buk[a]);
    }
}

int dojrzale(int a, int b)
{
    int fini = R[buk[a]];
    int qans = 0;
    proc(buk[a]);
    while(a <= b && a <= fini)
    {
        if(v[a] >= K)
            ++qans;
        ++a;
    }
    while(a < N && R[buk[a]] <= b)
        qans += aans[buk[a]], a = R[buk[a]] + 1;
    if(a <= b)
    {
        proc(buk[a]);
        fini = R[buk[a]];
        while(a <= b && a <= fini)
        {
            if(v[a] >= K)
                ++qans;
            ++a;
        }
    }
    return qans;
}

int main()
{
    int D[MAXN];
    int num_calls, i;
    int n, k;
    cin >> n >> k;
    for (i = 0; i < n; ++i)
        cin >> D[i];
    inicjuj(n,k, D);
    cin >> num_calls;
    for (i = 1; i <= num_calls; i++)
    {
        char call;
        int a, b;
        cin >> call >> a >> b;
        if (call == 'p')
            podlej(a, b);
        else
            cout << dojrzale(a, b) << '\n';
    }
    return 0;
}

Compilation message

/tmp/ccja6JXL.o: In function `main':
kongrader.cpp:(.text.startup+0x0): multiple definition of `main'
/tmp/ccuCdsyd.o:kon.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status