답안 #472234

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
472234 2021-09-13T09:59:24 Z balbit 푸드 코트 (JOI21_foodcourt) C++14
컴파일 오류
0 ms 0 KB
#include<bits/stdc++.h>
using namespace std;

#define ll long long
#define pii pair<ll, ll>
#define f first
#define s second

#define REP(i,n) for(int i = 0; i<n; ++i)

#ifdef BALBIT
#define bug(...) cerr<<"#"<<__LINE__<<"- "<<#__VA_ARGS__<<": ", _do(__VA_ARGS__)
template<typename T> void _do(T &&x) {cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S&& ...y) {cerr<<x<<", "; _do(y...);}
#else
#define bug(...)
#define endl '\n'
#endif

const int N = 250000;
const ll inf = 3e18;

ll bs[N];

void mo(int e, ll v) {
    for(++e; e<N; e+=e&-e) bs[e] += v;
}
void qu(int e) {
    ll re = 0;
    for(++e; e>0; e-=e&-e) re += bs[e];
    return re;
}

ll s[N*4], mn[N*4], tg[N*4];
ll who[N]; // which group is added at this time

void push(int o, int l, int r) {
    if(tg[o]) {
        s[o] += tg[o];
        mn[o] += tg[o];
        if(l!=r) {
            tg[o*2] += tg[o];
            tg[o*2+1] += tg[o];
        }
        tg[o] = 0;
    }
}

ll QU(int L, int R, int o=1, int l=0, int r=N-1) {
    if(l > R || r<L) return inf;
    push(o,l,r);
    if(l>=L && r <=R) {
        return mn[o];
    }
    int mid = (l+r)/2;
    return min(
               QU(L,R,o*2,l,mid),
               QU(L,R,o*2+1,mid+1,r);
               );
}

ll GET(int p, int o=1, int l=0, int r=N-1) {
    if (l > p || r < p) return -1;
    push(o,l,r);
    if(l==r) return s[o];
    int mid = (l+r)/2;
    return p<=mid?GET(p,o*2,l,mid) : GET(p,o*2+1,mid+1,r);
}

void MO(int L, int R, ll v, int o=1, int l=0, int r = N-1) {
    push(o,l,r);
    if(l > R ||r < L) return;
    if(l>=L && r <=R) {
        tg[o] += v;
        push(o,l,r);
        return;
    }
    s[o] = s[o*2]+s[o*2+1];
    mn[o] = min(mn[o*2], mn[o*2+1]);
}

vector<pii>ev[N]; // {position, value}
vector<pii> que[N]; // {position, number};

int ans[maxn];

signed main() {
    ios::sync_with_stdio(0), cin.tie(0);
    int n,m,q; cin>>n>>m>>q;
    memset(ans, -1, sizeof ans);
    REP(i,q) {
        int tp ;cin>>tp;
        if(tp == 1) {
            ll l,r,c,k; cin>>l>>r>>c>>k;
            who[i] = c;// group set
            ev[l].pb({i,k});
            ev[r+1].pb({i,-k});
        }else if (tp == 2) {
            ll l,r,k; cin>>l>>r>>k;
            ev[l].pb({i,-k});
            ev[r+1].pb({i,+k});
        }else if (tp == 3) {
            ll a,b; cin>>a>>b;
            que[a].pb({i, b});
        }
    }

    for(int i=1; i<=n; ++i) {
        for(pii p : ev[i]) {
            int at = p.f;
            ll val = p.s;
            MO(at, N-1, val);
        }
        for(pii p : que[i]) {
            int at = p.f;
            ll num = p.s;
            ll low = QU(0, at);
            ll val = GET(at);
            if (val - low >= num) {
                // continue here
            }
        }
    }

}

Compilation message

foodcourt.cpp: In function 'void qu(int)':
foodcourt.cpp:32:12: error: return-statement with a value, in function returning 'void' [-fpermissive]
   32 |     return re;
      |            ^~
foodcourt.cpp: In function 'long long int QU(int, int, int, int, int)':
foodcourt.cpp:59:37: error: expected ')' before ';' token
   59 |                QU(L,R,o*2+1,mid+1,r);
      |                                     ^
      |                                     )
foodcourt.cpp:57:15: note: to match this '('
   57 |     return min(
      |               ^
foodcourt.cpp:60:16: error: expected primary-expression before ')' token
   60 |                );
      |                ^
foodcourt.cpp: At global scope:
foodcourt.cpp:86:9: error: 'maxn' was not declared in this scope; did you mean 'mn'?
   86 | int ans[maxn];
      |         ^~~~
      |         mn
foodcourt.cpp: In function 'int main()':
foodcourt.cpp:91:12: error: 'ans' was not declared in this scope; did you mean 'abs'?
   91 |     memset(ans, -1, sizeof ans);
      |            ^~~
      |            abs
foodcourt.cpp:97:19: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'pb'
   97 |             ev[l].pb({i,k});
      |                   ^~
foodcourt.cpp:98:21: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'pb'
   98 |             ev[r+1].pb({i,-k});
      |                     ^~
foodcourt.cpp:101:19: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'pb'
  101 |             ev[l].pb({i,-k});
      |                   ^~
foodcourt.cpp:102:21: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'pb'
  102 |             ev[r+1].pb({i,+k});
      |                     ^~
foodcourt.cpp:105:20: error: 'class std::vector<std::pair<long long int, long long int> >' has no member named 'pb'
  105 |             que[a].pb({i, b});
      |                    ^~