Submission #431426

# Submission time Handle Problem Language Result Execution time Memory
431426 2021-06-17T11:51:17 Z Hideo Food Court (JOI21_foodcourt) C++17
0 / 100
93 ms 7680 KB
#include <bits/stdc++.h>
using namespace std;

#define all(s) s.begin(), s.end()
#define int long long
#define ll long long
#define fr first
#define sc second
#define pb push_back
#define mk make_pair
#define pi pair < int, int >

const int N = 65007;
const int INF = 1e9 + 7;

ll cnt[N];
int clr[N];
int n, m, q;

vector < pi > nxt[N];
vector < pi > gt[N];

int ans[N];

int t[4 * N];

void upd (int v, int l, int r, int pos, int val){
    if (l == r)
        t[v] += val;
    else {
        int mid = (l + r) >> 1;
        if (pos <= mid)
            upd(v + v, l, mid, pos, val);
        else
            upd(v + v + 1, mid + 1, r, pos, val);
        t[v] = t[v + v] + t[v + v + 1];
    }
}

int get (int v, int l, int r, int val){
    if (l == r)
        return clr[l];
    int mid = (l + r) >> 1;
    if (t[v + v] >= val)
        return get(v + v, l, mid, val);
    val -= t[v + v];
    return get(v + v + 1, mid + 1, r, val);
}

main (){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> q;
    for (int i = 1; i <= q; i++){
        int t;
        cin >> t;
        if (t == 1){
            int l, r, c, k;
            cin >> l >> r >> c >> k;
            clr[i] = c;
            nxt[l].pb({i, k});
            nxt[r + 1].pb({i, -k});
        }
        else if (t == 3){
            int a;
            ll b;
            cin >> a >> b;
            gt[a].pb({i, b});
        }
        else
            return 0;
    }
    for (int i = 1; i <= n; i++){
        for (auto it : nxt[i]){
            upd(1, 1, q, it.fr, it.sc);
        }
        for (auto it : gt[i]){
            if (t[1] < it.sc)
                ans[it.fr] = -1;
            else
                ans[it.fr] = get(1, 1, it.fr, it.sc);
        }
    }
    for (int i = 1; i <= q; i++){
        if (ans[i] == -1)
            cout << 0 << endl;
        else if (ans[i])
            cout << ans[i] << endl;
    }
}

Compilation message

foodcourt.cpp:50:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   50 | main (){
      | ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 6696 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 93 ms 7680 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 3276 KB Output isn't correct
2 Halted 0 ms 0 KB -