QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#487169 | #2672. Rectangles | Dan4Life | 0 | 11ms | 6120kb | C++23 | 1.6kb | 2024-07-22 17:20:56 | 2024-07-22 17:20:57 |
Judging History
answer
#include "rect.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
const int mxN = 2502;
int n, m;
int pref[mxN][mxN], fen[mxN][mxN];
vector<int> row[mxN][mxN], col[mxN][mxN];
void upd(int i, int x, int v){
for(++x; x<mxN; x+=x&-x)
fen[i][x]+=v;
}
int sum(int i, int x){
int s = 0;
for(++x; x>0; x-=x&-x) s+=fen[i][x];
return s;
}
int sum(int i, int l, int r){
if(l>r)return 0;
return sum(i,r)-sum(i,l-1);
}
ll count_rectangles(vector<vi> a) {
n = sz(a); m = sz(a[0]);
ll ans = 0;
for(int i = 0; i < n; i++){
stack<int> S = stack<int>();
for(int j = m-1; j >= 0; j--){
while(sz(S) and a[i][S.top()]<a[i][j]) S.pop();
if(sz(S) and abs(S.top()-j)!=1){
row[i][j].pb(S.top());
}
S.push(j);
}
}
for(int j = 0; j < m; j++){
stack<int> S = stack<int>();
for(int i = n-1; i >= 0; i--){
while(sz(S) and a[S.top()][j]<a[i][j]) S.pop();
if(sz(S) and abs(S.top()-i)!=1){
col[i][j].pb(S.top());
}
S.push(i);
}
}
for(int i = 1; i < n-1; i++){
for(int j = 0; j < m; j++)
for(auto u : col[i-1][j]) upd(u,j,1);
for(int j = 0; j < m; j++){
for(auto k : row[i][j]){
//we have fixed j... k
//we have fixed i
for(auto l : col[i-1][j+1]){
//cout << i << " " << j << " " << k << "\n";
if(sum(l,j,k)!=k-j-1)continue;
ans++;
}
}
for(auto u : col[i-1][j]) upd(u,j,-1);
}
}
return ans;
}
詳細信息
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 11ms
memory: 6088kb
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 0
result:
wrong answer 3rd lines differ - expected: '784', found: '0'
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: 0
Wrong Answer
time: 7ms
memory: 4240kb
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 0
result:
wrong answer 3rd lines differ - expected: '2498', found: '0'
Subtask #6:
score: 0
Wrong Answer
Test #64:
score: 0
Wrong Answer
time: 10ms
memory: 6120kb
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 3
result:
wrong answer 3rd lines differ - expected: '2', found: '3'
Subtask #7:
score: 0
Skipped
Dependency #1:
0%