QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#677815#9249. Elimination Series Once Moreveg#WA 1ms7876kbC++20581b2024-10-26 13:28:402024-10-26 13:28:41

Judging History

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

  • [2024-10-26 13:28:41]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:7876kb
  • [2024-10-26 13:28:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
int n, k, a[1 << 20 | 5], idx[1 << 20 | 5], ans[1 << 20 | 5], t[1 << 20 | 5];
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= 1 << n; ++i) {
		scanf("%d", &a[i]);
		idx[a[i]] = i;
	}
	for (int i = 1 << n; i >= 1; --i) {
		int p = idx[i], len = 2;
		while (p) {
			if (t[p] <= k && i >= len) {
				++ans[idx[i]];
				p >>= 1;
				len <<= 1;
			} else 
				break;
		}
		p = idx[i];
		while (p) {
			t[p] += 1;
			p >>= 1;
		}
	}
	for (int i = 1; i <= 1 << n; ++i) printf("%d ", ans[i]);
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

2 1
1 2 3 4

output:

0 1 1 2 

result:

ok 4 number(s): "0 1 1 2"

Test #2:

score: -100
Wrong Answer
time: 1ms
memory: 7876kb

input:

3 5
2 4 7 5 3 8 6 1

output:

0 2 2 2 1 3 2 0 

result:

wrong answer 1st numbers differ - expected: '1', found: '0'