Submission #430349

# Submission time Handle Problem Language Result Execution time Memory
430349 2021-06-16T13:04:37 Z arayi Pyramid Base (IOI08_pyramid_base) C++17
44 / 100
5000 ms 103256 KB
//Arayi
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <math.h>   
#include <vector>
#include <cstring>
#include <ctime>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <ctime>
#include <climits>
#include <cassert>
#include <chrono>
#include <random>
#include <complex>

#define fr first
#define sc second
#define MP make_pair
#define ad push_back
#define PB push_back
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define lli long long int
#define y1 arayikhalatyan
#define j1 jigglypuff
#define ld long double
#define itn int
#define pir pair<int, int>
#define all(x) (x).begin(), (x).end()
#define str string
#define enl endl
#define en endl
#define cd complex<long double>
#define vcd vector<cd>
#define vii vector<int>
#define vlli vector<lli>
using namespace std;

const int N = 1e6 + 30;


int n, k, m, p;
int x1[N], x2[N], y1[N], y2[N], c[N];
vector <pair<pair<int, int>, int> > fp[N];
lli t[4*N], flg[4*N];
void bld(int l = 1, int r = m, int nd = 1)
{
    t[nd] = flg[nd] = 0;
    if(l == r) return;
    int md = (l + r) / 2;
    bld(l, md, nd*2);
    bld(md + 1, r, nd*2+1);
}
void push(int nd)
{
    t[nd] += flg[nd];
    flg[nd*2] += flg[nd];
    flg[nd*2+1] += flg[nd];
    flg[nd] = 0;
}
void upd(int l, int r, lli v, int nl = 1, int nr = m, int nd = 1)
{
    push(nd);
    if(l > nr || r < nl) return;
    if(l == nl && nr == r)
    {
        flg[nd] += v;
        push(nd);
        return;
    }
    int mid = (nl + nr) / 2;
    upd(l, min(mid, r), v, nl, mid, nd*2);
    upd(max(mid + 1, l), r, v, mid + 1, nr, nd * 2 + 1);
    t[nd] = min(t[nd*2], t[nd*2+1]);
}   
int stg(int md)
{
    bld();
    upd(m - md + 2, m, k + 1);
    for (int i = 1; i <= n - md + 1; i++)
    {
        for(auto& p : fp[i]) upd(p.fr.fr, p.fr.sc, p.sc);//, cout << p.fr.fr << " " << p.fr.sc << " " << p.sc << endl;
        push(1);
        if(t[1] <= k) return i;
    }
    return 0;
}
int main()
{
    fastio;
    //freopen("input.in", "r", stdin);
    cin >> n >> m >> k >> p;
    for (int i = 0; i < p; i++) cin >> x1[i] >> y1[i] >> x2[i] >> y2[i] >> c[i];
    int l = 1, r = min(n, m), ans = 0;
    while(l <= r)
    {
        int md = (l + r) / 2;
        for (int i = 0; i < p; i++)
        {
            fp[max(1, x1[i] - md + 1)].ad(MP(MP(max(1, y1[i] - md + 1), y2[i]), c[i]));
            fp[x2[i] + 1].ad(MP(MP(max(1, y1[i] - md + 1), y2[i]), -c[i]));
        }
        if(stg(md)) ans = md, l=md+1;
        else r=md-1;
        for (int i = 0; i <= n + 1; i++) fp[i].clear();
    }
    cout << ans << endl;
    return 0;
}

/*
    __
  *(><)*
    \/ /
    ||/
  --||
    ||
    /\
   /  \
  /    \

*/
# Verdict Execution time Memory Grader output
1 Correct 19 ms 23804 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 17 ms 23756 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 23 ms 23880 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 28 ms 24716 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 73 ms 30180 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 292 ms 59288 KB Output is correct
2 Incorrect 408 ms 67412 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 388 ms 68520 KB Output is correct
2 Correct 280 ms 59520 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 52 ms 24908 KB Output is correct
2 Correct 104 ms 25148 KB Output is correct
3 Correct 77 ms 25108 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 368 ms 32572 KB Output is correct
2 Correct 644 ms 32988 KB Output is correct
3 Correct 462 ms 33512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1020 ms 75916 KB Output is correct
2 Correct 123 ms 28720 KB Output is correct
3 Correct 384 ms 73104 KB Output is correct
4 Incorrect 1613 ms 79264 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 1439 ms 79168 KB Output is correct
2 Incorrect 2029 ms 82680 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1495 ms 77384 KB Output is correct
2 Incorrect 3026 ms 84488 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5097 ms 96172 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5101 ms 97296 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 5103 ms 103256 KB Time limit exceeded
2 Halted 0 ms 0 KB -