QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#663083 | #2672. Rectangles | Dimash# | 0 | 4ms | 20572kb | C++17 | 1.9kb | 2024-10-21 12:52:40 | 2024-10-21 12:52:40 |
Judging History
answer
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 2500 + 12;
int n, m, a[N][N], u[N][N], d[N][N], l[N][N], r[N][N];
void prec() {
for(int i = 1; i <= n; i++) {
vector<int> st;
for(int j = 1; j <= m; j++) {
while(!st.empty() && a[i][st.back()] <= a[i][j]) {
st.pop_back();
}
l[i][j] = (st.empty() ? 0 : st.back());
st.push_back(j);
}
st.clear();
for(int j = m; j >= 1; j--) {
while(!st.empty() && a[i][st.back()] <= a[i][j]) {
st.pop_back();
}
r[i][j] = (st.empty() ? m + 1 : st.back());
st.push_back(j);
}
}
for(int j = 1; j <= m; j++) {
vector<int> st;
for(int i = 1; i <= n; i++) {
while(!st.empty() && a[st.back()][j] <= a[i][j]) {
st.pop_back();
}
u[i][j] = (st.empty() ? 0 : st.back());
st.push_back(i);
}
st.clear();
for(int i = n; i >= 1; i--) {
while(!st.empty() && a[st.back()][j] <= a[i][j]) {
st.pop_back();
}
d[i][j] = (st.empty() ? n + 1 : st.back());
st.push_back(i);
}
}
// for(int i = 1; i <= n; i++) {
// for(int j = 1; j <= m; j++) {
// cout << l[i][j] << ' ';
// }
// cout << '\n';
// }
}
ll count_rectangles(vector<vector<int> > _A) {
n = (int)_A.size();
m = (int)_A[0].size();
for(int i = 1; i <= n; i++) {
for(int j = 1; j <= m; j++) {
a[i][j] = _A[i - 1][j - 1];
}
}
prec();
ll res = 0;
for(int i = 2; i < n; i++) {
vector<int> x(m + 1, m + 1), y(m + 1, 0);
for(int j = i; j < n; j++) {
for(int k = 2; k < m; k++) {
x[k] = min(x[k], r[j][k - 1]);
y[k] = max(y[k], l[j][k + 1]);
}
for(int k = 2; k < m; k++) {
for(int f = k; f < m; f++) {
if(d[i - 1][f] <= j || u[j + 1][f] >= i) {
break;
}
// cout << i << ' ' << j << ' ' << k << ' ' << f << ' ' << x[k] << ' ' << y[f] << '\n';
if(x[k] > f && y[f] < k) {
res++;
}
}
}
}
}
return res;
}
详细
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 8
Accepted
time: 0ms
memory: 20300kb
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: 8
Accepted
time: 0ms
memory: 18196kb
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: 8
Accepted
time: 2ms
memory: 12100kb
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
Wrong Answer
time: 2ms
memory: 20572kb
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 164836
result:
wrong answer 3rd lines differ - expected: '0', found: '164836'
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: 4ms
memory: 12228kb
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: 10
Accepted
time: 0ms
memory: 12116kb
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
Wrong Answer
time: 4ms
memory: 12176kb
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 3121251
result:
wrong answer 3rd lines differ - expected: '0', found: '3121251'
Subtask #6:
score: 0
Wrong Answer
Test #64:
score: 0
Wrong Answer
time: 1ms
memory: 12360kb
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 116
result:
wrong answer 3rd lines differ - expected: '2', found: '116'
Subtask #7:
score: 0
Skipped
Dependency #1:
0%