QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#623202#8781. Element-Wise Comparisonrns_jkRE 0ms0kbC++14971b2024-10-09 10:35:362024-10-09 10:35:38

Judging History

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

  • [2024-10-09 10:35:38]
  • 评测
  • 测评结果:RE
  • 用时:0ms
  • 内存:0kb
  • [2024-10-09 10:35:36]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define N 50001
// #define N 5
using ll = long long;
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, m;
    cin >> n >> m;
    vector<int> p(n), q(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i];
        p[i]--;
        q[p[i]] = i;  
    }
    vector<bitset<N>> c(n), pre(n + 1), suf(n);
    bitset<N> u;
    for (int i = 0; i < n; i++) u.set(i);
    for (int i = 0; i < n; i++) {
        u.set(q[i], false);
        c[q[i]] = u;
    }
      
    for (int i = 1; i < n; i++) c[i] = c[i] >> i;
    for (int i = 0; i < n; i ++) {
        if (i % m == 0) suf[i] = c[i];
        else suf[i] = suf[i - 1] & c[i];
    }
    u = 0;
    ll ret = 0;

    for (int i = n - 1; i >= 0; i--) {
        if (i % m == 0) u = c[i];
        else u &= c[i];
        ret += (u & suf[i + m - 1]).count();
    }
    
    
    
    cout << ret << endl;
    
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Runtime Error

input:

5 3
5 2 1 3 4

output:


result: