QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#592904#8781. Element-Wise ComparisoncaijianhongWA 262ms614656kbC++231.0kb2024-09-27 09:43:542024-09-27 09:43:54

Judging History

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

  • [2024-09-27 09:43:54]
  • 评测
  • 测评结果:WA
  • 用时:262ms
  • 内存:614656kb
  • [2024-09-27 09:43:54]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#define debug(...) fprintf(stderr, ##__VA_ARGS__)
#else
#define endl "\n"
#define debug(...) void(0)
#endif
using LL = long long;
int n, m, a[50010];
bitset<50010> bs[50010], pre[50010];
int main() {
#ifndef LOCAL
  cin.tie(nullptr)->sync_with_stdio(false);  
#endif
  cin >> n >> m;
  for (int i = 1, x; i <= n; i++) cin >> x, a[x] = i;
  bitset<50010> tmp;
  for (int x = n; x >= 1; x--) {
	  int i = a[x];
	  bs[i] = tmp >> i;
	  tmp[i] = true;
  }
  LL ans = 0;
#ifdef LOCAL
  for (int i = 1; i <= n; i++) {
	  for (int j = 0; j < n; j++) debug("%d", (int)bs[i][j]);
	  debug("\n");
  }
#endif
  for (int i = m; i <= n; i += m) {
	  pre[i - 1].set();
	  for (int j = i; j <= n && j <= i + m; j++) pre[j] = pre[j - 1] & bs[j - 1];
	  bitset<50010> now = bs[i];
	  for (int j = i; j > i - m; j--) {
		  now &= bs[j];
		  if (j + m <= n + 1) ans += (now & pre[j + m]).count();
	  }
  }
  cout << ans << endl;
  return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5652kb

input:

5 3
5 2 1 3 4

output:

0

result:

ok answer is '0'

Test #2:

score: 0
Accepted
time: 1ms
memory: 7696kb

input:

5 2
3 1 4 2 5

output:

2

result:

ok answer is '2'

Test #3:

score: 0
Accepted
time: 1ms
memory: 5956kb

input:

4 2
1 2 3 4

output:

3

result:

ok answer is '3'

Test #4:

score: 0
Accepted
time: 1ms
memory: 5704kb

input:

4 2
4 3 2 1

output:

0

result:

ok answer is '0'

Test #5:

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

input:

1 1
1

output:

0

result:

ok answer is '0'

Test #6:

score: -100
Wrong Answer
time: 262ms
memory: 614656kb

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:

233533146

result:

wrong answer expected '310780127', found '233533146'