QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#131379#2672. Rectanglessomethingnew#0 618ms98120kbC++204.8kb2023-07-27 02:02:272024-07-04 00:57:49

Judging History

你现在查看的是最新测评结果

  • [2024-07-04 00:57:49]
  • 评测
  • 测评结果:0
  • 用时:618ms
  • 内存:98120kb
  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-07-27 02:02:27]
  • 提交

answer

//  ↘ ⬇ ⬇ ⬇ ⬇ ⬇ ↙
//  ➡ @roadfromroi ⬅
//  ↗ ⬆ ⬆ ⬆ ⬆ ⬆ ↖
#include <iostream>
#include "vector"
#include "algorithm"
#include "numeric"
#include "climits"
#include "iomanip"
#include "bitset"
#include "cmath"
#include "map"
#include "deque"
#include "array"
#include "set"
#include "rect.h"
#define all(x) x.begin(), x.end()
using namespace std;
//#define LOCAL 1
struct segtree {
    int sz;
    vector<int> tree;
    void init(int n) {
        sz = 1;
        while (sz < n) {
            sz *= 2;
        }
        tree.assign(sz * 2, {});
    }
    int get(int l, int r) {
        l += sz;
        r += sz;
        int res = 0;
        while (l <= r) {
            if (l % 2) {
                res += tree[l];l++;
            }
            if (r % 2 == 0) {
                res += tree[r];
                r--;
            }
            l /= 2;r /= 2;
        }
        return res;
    }
    void ch(int v, int x) {
        v += sz;
        tree[v] += x;
        while (v != 1) {
            v /= 2;
            tree[v] = tree[v * 2] + tree[v * 2 + 1];
        }
    }
};
vector<array<int, 3>> retar(vector<int> & a, int tosrt = 1) {
    int n = a.size();
    vector<int> nxtmore(n), prvmore(n);
    for (int i = 0; i < n; ++i) {
        prvmore[i] = i-1;
        while (prvmore[i] != -1 and a[i] > a[prvmore[i]])
            prvmore[i] = prvmore[prvmore[i]];
    }
    for (int i = n - 1; i >= 0; --i) {
        nxtmore[i] = i+1;
        while (nxtmore[i] != n and a[i] > a[nxtmore[i]])
            nxtmore[i] = nxtmore[nxtmore[i]];
    }
    vector<array<int, 3>> segs;
    for (int i = 0; i < n; ++i) {
        if (nxtmore[i] < n and i+2 <= nxtmore[i]) {
            segs.push_back({i+1, nxtmore[i] - 1, 1});
        }
        if (prvmore[i] > -1 and prvmore[i] + 1 <= i - 1 and a[prvmore[i]] > a[i]) {
            segs.push_back({prvmore[i] + 1, i - 1, 1});
        }
    }
    if (tosrt)
        sort(all(segs));
    return segs;
}
void updlst(vector<array<int, 3>> &a, vector<array<int, 3>> &b, vector<array<int, 3>> &toaddkaa) {
    int v1 = 0;
    for (auto &i : b) {
        while (v1 != a.size() and make_pair(a[v1][0], a[v1][1]) < make_pair(i[0], i[1])) {
            toaddkaa.push_back(a[v1]);
            v1++;
        }
        if (v1 != a.size() and make_pair(a[v1][0], a[v1][1]) == make_pair(i[0], i[1])) {
            i[2] = a[v1][2] + 1;
            v1++;
        }
    }
    while (v1 != a.size()) {
        toaddkaa.push_back(a[v1]);
        v1++;
    }
}
long long count_rectangles(std::vector<std::vector<int> > a) {
    vector<vector<array<int, 3>>> bebas(a.size());
    vector<vector<array<int, 3>>> zpr2(a[0].size());
    for (int i = 1; i < a.size(); ++i) {
        bebas[i] = retar(a[i]);
        if (i + 1 == a.size())
            bebas[i] = {};
        vector<array<int, 3>> losed;
        updlst(bebas[i-1], bebas[i], losed);
        for (auto [l1, r1, glb] : bebas[i]) {
            int r2 = i;
            int l2 = i;
            zpr2[r1].push_back({l2, r2, r1-l1+1});
            //cout << "D " << l1 << ' ' << r1 << ' ' << l2 << ' ' << r2 << endl;
        }
        for (auto [l1, r1, glb] : losed) {
            int r2 = i - 1;
            int l2 = i - glb;
            zpr2[r1].push_back({l2, r2, r1-l1+1});
            //cout << l1 << ' ' << r1 << ' ' << l2 << ' ' << r2 << endl;
        }
    }
    vector<vector<int>> a2(a[0].size(), vector<int>(a.size()));
    for (int i = 0; i < a.size(); ++i) {
        for (int j = 0; j < a[i].size(); ++j) {
            a2[j][i] = a[i][j];
        }
    }
    for (int i = 0; i < a2.size(); ++i) {
        for (int j = 0; j < a2[i].size(); ++j) {
            //cout << a2[i][j] << ' ';
        }
        //cout << '\n';
    }
    long long reska = 0;
    vector<vector<array<int, 3>>> bebas2(a2.size());
    for (int i = 1; i + 1 < a2.size(); ++i) {
        bebas2[i] = retar(a2[i]);
        vector<array<int, 3>> losed;
        updlst(bebas2[i-1], bebas2[i], losed);
        for (auto teba : bebas2[i]) {
            int mglb = 0;
            for (auto jeba : zpr2[i]) {
                if (teba[2] >= jeba[2] and jeba[0] <= teba[0] and teba[1] <= jeba[1]) {
                    mglb = max(mglb, jeba[2]);
                    //cout  << i << ' ' << teba[0] << ' ' << teba[1] << ' ' << jeba[0] << ' ' << jeba[1] << endl;
                }
            }
            reska += mglb;
        }
    }
    return reska;
}

#ifdef LOCAL

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> a(n, vector<int>(m));
    for (int i = 0; i < n; i++)	{
        for (int j = 0; j < m; j++) {
            cin >> a[i][j];
        }
    }

    long long result = count_rectangles(a);
    cout << result << '\n';
    return 0;
}

#endif

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 8
Accepted
time: 1ms
memory: 4048kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
30 30
3996 3689 3664 3657 3646 3630 3621 3619 3609 3604 3601 3598 3584 3581 3574 3561 3554 3543 3537 3531 3522 3519 3505 3500 3498 3492 3476 3467 3460 3994
3993 3458 3451 3440 3431 3420 3395 3346 3333 3282 3268 3261 3241 3204 3168 3121 3103 3083 3076 2923 2872 28...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
784

result:

ok 3 lines

Test #2:

score: 0
Accepted
time: 0ms
memory: 4124kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
30 30
6996495 6421812 6403903 6382663 6362922 6334993 6329757 6315983 6278578 6262778 6254104 6244987 6232172 6226987 6194797 6176457 6167900 6140865 6123884 6116295 6101556 6079188 6068604 6049308 6034911 6034041 6015464 6004614 5992300 6995512
6987555 5978527 5...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
784

result:

ok 3 lines

Test #3:

score: 0
Accepted
time: 0ms
memory: 3764kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
30 30
12330 11301 11283 11257 11240 11194 11170 11135 11116 11095 11085 11048 11000 10972 10914 10909 10897 10877 10835 10823 10789 10781 10769 10745 10708 10690 10665 10661 10645 12329
12326 10635 10633 10590 10557 10542 10513 10491 10418 10406 10096 10086 9930 ...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
784

result:

ok 3 lines

Test #4:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
30 30
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Test #5:

score: -8
Wrong Answer
time: 0ms
memory: 3800kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
30 30
1023589 2780022 3479561 3782160 3952727 450470 3945264 2170843 3225056 1786041 1389306 1419234 3915988 520009 1251948 104723 1856504 3637799 1807024 2170722 2803041 2964655 2003819 1048641 3939016 2826494 3085605 1000286 3022731 1498648
3779781 3073573 7294...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
314

result:

wrong answer 3rd lines differ - expected: '268', found: '314'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #2:

0%

Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Wrong Answer

Test #53:

score: 10
Accepted
time: 1ms
memory: 4580kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
3999533 3994407 3992243 3991052 3990430 3988819 3987546 3985557 3983808 3983398 3982565 3981632 3981437 3979888 3979428 3978697 3978033 3975044 3973166 3972565 3971499 3970538 3969576 3969014 3968513 3968337 3966950 3965168 3964140 3963957 3962080 3961829 ...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
2498

result:

ok 3 lines

Test #54:

score: 0
Accepted
time: 0ms
memory: 4188kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2123
3999178 3994918 3993586 3990671 3989261 3988091 3985537 3984649 3983635 3982639 3981319 3980647 3979462 3978557 3977387 3976784 3975890 3975694 3975367 3975193 3973331 3971593 3970332 3969892 3968052 3967213 3966031 3963229 3963001 3962625 3961725 3959892 ...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
2121

result:

ok 3 lines

Test #55:

score: 0
Accepted
time: 1ms
memory: 4328kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Test #56:

score: 0
Accepted
time: 0ms
memory: 3800kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 1
2
0
3

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
0

result:

ok 3 lines

Test #57:

score: -10
Wrong Answer
time: 1ms
memory: 4620kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
3 2500
3073920 3547280 2578996 515881 1457637 3747191 3335718 1093356 188596 2501359 1707005 923685 1254329 1274578 2451887 1948214 3495100 706306 2036295 3924470 2870740 2253399 2559834 2223853 3524040 448754 2838433 2573451 1627516 2712253 1015735 1941089 29861...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
819

result:

wrong answer 3rd lines differ - expected: '688', found: '819'

Subtask #6:

score: 0
Wrong Answer

Test #64:

score: 13
Accepted
time: 0ms
memory: 3720kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
10 10
1 1 0 0 1 0 0 1 0 0
0 1 0 0 1 0 0 1 1 0
0 1 0 0 0 0 0 1 1 0
1 0 0 0 1 0 0 0 1 1
1 0 1 1 0 0 1 1 0 1
0 0 1 0 0 0 1 1 0 0
1 0 1 1 1 1 1 1 1 0
1 0 0 0 1 1 1 1 0 0
1 0 0 1 1 0 1 0 1 1
0 0 0 0 0 1 0 1 1 0

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
2

result:

ok 3 lines

Test #65:

score: -13
Wrong Answer
time: 618ms
memory: 98120kb

input:

8d9a74d5-4c4b-4437-9c49-114beaeb8f1a
1234 2321
0 0 0 1 0 0 0 1 0 0 0 1 1 1 0 1 1 1 0 0 0 0 1 1 1 1 0 1 0 0 0 1 0 0 0 1 1 0 0 0 0 0 1 1 0 1 1 1 1 1 1 1 1 0 0 0 1 0 0 1 1 0 1 1 1 1 1 0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 0 1 0 0 1 0 1 0 0 1 1 0 0 1 0 0 0 1 0 1 0 0 1 0 0 1 0 1 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 1 1...

output:

907404fa-efbb-4a2c-83b8-4c377409c80c
OK
132407

result:

wrong answer 3rd lines differ - expected: '116238', found: '132407'

Subtask #7:

score: 0
Skipped

Dependency #1:

0%