QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#640263#8781. Element-Wise Comparisonqianchen06WA 0ms3848kbC++14930b2024-10-14 10:09:252024-10-14 10:09:28

Judging History

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

  • [2024-10-14 10:09:28]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3848kb
  • [2024-10-14 10:09:25]
  • 提交

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'