QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#640263 | #8781. Element-Wise Comparison | qianchen06 | WA | 0ms | 3848kb | C++14 | 930b | 2024-10-14 10:09:25 | 2024-10-14 10:09:28 |
Judging History
answer
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;
const int MAXN = 50000;
bitset<MAXN> bits[MAXN]; // 用于存储布尔矩阵
int main() {
int n, m;
cin >> n >> m;
vector<int> p(n);
for (int i = 0; i < n; ++i) {
cin >> p[i];
}
// 构建布尔矩阵 C[l,s]
for (int l = 0; l < n; ++l) {
for (int s = 1; l + s < n; ++s) {
if (p[l] < p[l + s]) {
bits[l][s] = 1;
}
}
}
int count = 0;
// 选择步长为 m 的枢轴元素,进行前缀和后缀 OR 操作
for (int i = 0; i + m < n; ++i) {
for (int j = i + m; j + m <= n; ++j) {
// 通过位集快速计算前缀和后缀 OR 结果
if ((bits[i] & bits[j]).count() == m) {
count++;
}
}
}
cout << count << endl;
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3848kb
input:
5 3 5 2 1 3 4
output:
0
result:
ok answer is '0'
Test #2:
score: -100
Wrong Answer
time: 0ms
memory: 3848kb
input:
5 2 3 1 4 2 5
output:
0
result:
wrong answer expected '2', found '0'