QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#447874#8781. Element-Wise Comparisonucup-team037WA 214ms309440kbC++201.9kb2024-06-18 22:58:452024-06-18 22:58:46

Judging History

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

  • [2024-06-18 22:58:46]
  • 评测
  • 测评结果:WA
  • 用时:214ms
  • 内存:309440kb
  • [2024-06-18 22:58:45]
  • 提交

answer


// Hallelujah, praise the one who set me free
// Hallelujah, death has lost its grip on me
// You have broken every chain, There's salvation in your name
// Jesus Christ, my living hope
#include <bits/stdc++.h> 
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define RREP(i, s, e) for (int i = (s); i >= (e); i--)
template <class T>
inline bool mnto(T& a, T b) {return b < a ? a = b, 1 : 0;}
template <class T>
inline bool mxto(T& a, T b) {return a < b ? a = b, 1: 0;}

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define FI first
#define SE second
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef tuple<int, int, int> iii;
#define ALL(_a) _a.begin(), _a.end()
#define SZ(_a) (int) _a.size()
#define pb push_back
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<iii> viii;

#ifndef DEBUG
#define cerr if (0) cerr
#endif

const int INF = 1000000005;
const ll LINF = 1000000000000000005ll;
const int MAXN = 50005;

int n, m;
int p[MAXN], ip[MAXN];
bitset<MAXN> sp[MAXN];
int ans;

bitset<MAXN> qry(int s, int e) {
    int k = 31 - __builtin_clz(e - s + 1);
    return sp[k][s] & sp[k][e - (1 << k) + 1];
}

int main() {
#ifndef DEBUG
    ios::sync_with_stdio(0), cin.tie(0);
#endif
    cin >> n >> m;
    REP (i, 0, n) {
        cin >> p[i];
        p[i]--;
        ip[p[i]] = i;
    }
    bitset<MAXN> base;
    RREP (i, n - 1, 0) {
        sp[i] = base >> ip[i];
        base[ip[i]] = 1;
    }
    int gk = 31 - __builtin_clz(m);
    REP (k, 1, gk + 1) {
        REP (i, 0, n - (1 << k - 1)) {
            sp[i] = sp[i] & sp[i + (1 << k - 1)];
        }
    }
    REP (l, 0, n - m + 1) {
        bitset<MAXN> cur = sp[l] & sp[l + m - (1 << gk)];
        /*
        cur.set();
        REP (i, l, l + m) {
            cur &= dp[i];
        }
        */
        ans += cur.count();
    }
    cout << ans << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3616kb

input:

5 3
5 2 1 3 4

output:

0

result:

ok answer is '0'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3616kb

input:

5 2
3 1 4 2 5

output:

2

result:

ok answer is '2'

Test #3:

score: 0
Accepted
time: 0ms
memory: 3604kb

input:

4 2
1 2 3 4

output:

3

result:

ok answer is '3'

Test #4:

score: 0
Accepted
time: 0ms
memory: 3672kb

input:

4 2
4 3 2 1

output:

0

result:

ok answer is '0'

Test #5:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

1 1
1

output:

0

result:

ok answer is '0'

Test #6:

score: -100
Wrong Answer
time: 214ms
memory: 309440kb

input:

50000 2
44045 29783 5389 7756 44022 45140 21967 5478 10868 49226 21775 31669 49836 13511 46116 14229 27206 31168 37389 3158 10658 41154 14635 18526 40540 6451 23197 46719 30593 13517 8604 46666 39189 43746 12778 3684 3194 36979 43020 14652 19549 31178 17144 27177 44336 2849 40220 11751 41993 32209 4...

output:

277220463

result:

wrong answer expected '310780127', found '277220463'