답안 #882256

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
882256 2023-12-02T20:59:54 Z Regulus 푸드 코트 (JOI21_foodcourt) C++17
0 / 100
39 ms 17592 KB
#include <bits/stdc++.h>            // pA
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

const int N = 3e5+5;
//const int INF = 2e9;
ll Q, bit[N], a[N];
struct Query {
    ll t, tin, c, k;
    Query() {}
    Query(ll tt, ll tttt, ll cc, ll kk) : t(tt), tin(tttt), c(cc), k(kk) {}
};
vector<Query> v[N];

inline ll query(int x)
{
    ll ret = 0;
    for (int i=x; i > 0; i-=lowbit(i)) ret += bit[i];
    return ret;
}

inline void upd(ll x, ll val)
{
    for (int i=x; i <= Q; i+=lowbit(i)) bit[i] += val;
}

inline bool cmp(Query a, Query b)
{ return a.tin < b.tin; }

int main(void)
{ IO
    ll n, m, i, t, L, R, c, k, lb, ub, mid;

    cin >> n >> m >> Q;
    for (i=1; i <= Q; ++i)
    {
        cin >> t;
        if (t == 1)
        {
            cin >> L >> R >> c >> k;
            v[L].pb(t, i, c, k);
            v[R+1].pb(-t, i, c, k);
        } else if (t == 2) {
            assert(0);
        } else {
            cin >> L >> k;
            v[L].pb(t, i, 0, k);
        }
    }

    for (i=1; i <= n; ++i)
    {
        sort(all(v[i]), cmp);
        for (auto q : v[i])
        {
            if (q.t == 1) upd(q.tin, q.k), a[q.tin] = q.c;
            else if (q.t == -1) upd(q.tin, -q.k), a[q.tin] = 0;
            else {
                lb = 1, ub = q.tin;
                while (lb < ub)
                {
                    mid = (lb+ub)>>1;
                    if (query(mid) >= q.k) ub = mid;
                    else lb = mid + 1;
                }
                if (lb == q.tin) cout << "0\n";
                else cout << a[lb] << '\n';
            }
        }
    }


    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 17496 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 17496 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 9 ms 17496 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 11 ms 17592 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 17496 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 39 ms 14636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 17496 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 8 ms 17496 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -