QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#579238#8781. Element-Wise ComparisonSunsetGlow95WA 213ms309480kbC++14804b2024-09-21 10:53:302024-09-21 10:53:30

Judging History

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

  • [2024-09-21 10:53:30]
  • 评测
  • 测评结果:WA
  • 用时:213ms
  • 内存:309480kb
  • [2024-09-21 10:53:30]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

const int MXN = 50005;
int N, M, perm[MXN], ans, rev[MXN];
bitset<MXN> bs[MXN], cur;

int main() {
  cin >> N >> M;
  for (int i(0); i != N; ++i) cin >> perm[i], --perm[i], rev[perm[i]] = i;
  for (int i(N - 2); ~i; --i) {
    if (rev[i + 1] > rev[i])
      bs[rev[i]] = bs[rev[i + 1]] << (rev[i + 1] - rev[i]),
      bs[rev[i]].set(rev[i + 1] - rev[i]);
    else
      bs[rev[i]] = bs[rev[i + 1]] >> (rev[i] - rev[i + 1]);
  }
  for (int i(0); i * M < N; ++i) {
    for (int j(i * M + M - 2); j >= i * M; --j) bs[j] &= bs[j + 1];
    cur.set();
    for (int j(i * M); j != i * M + M; ++j) {
      ans += (bs[j] & cur).count();
      if (j + M == N) break;
      cur &= bs[j + M];
    }
  }
  cout << ans << endl;
  return 0;
}

詳細信息

Test #1:

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

input:

5 3
5 2 1 3 4

output:

0

result:

ok answer is '0'

Test #2:

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

input:

5 2
3 1 4 2 5

output:

2

result:

ok answer is '2'

Test #3:

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

input:

4 2
1 2 3 4

output:

3

result:

ok answer is '3'

Test #4:

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

input:

4 2
4 3 2 1

output:

0

result:

ok answer is '0'

Test #5:

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

input:

1 1
1

output:

0

result:

ok answer is '0'

Test #6:

score: -100
Wrong Answer
time: 213ms
memory: 309480kb

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:

23179

result:

wrong answer expected '310780127', found '23179'