QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#103274#5741. TriterminantwillowWA 5ms6788kbC++141.1kb2023-05-04 22:41:492023-05-04 22:43:58

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-04 22:43:58]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:6788kb
  • [2023-05-04 22:41:49]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int T, n, b[maxn], a[maxn], c[maxn], f[maxn][2];
vector<int> pos;
int lb(int x) {
	return x & -x;
}

bool pd(int x) {
	return lb(x + 1) == x + 1;
}

int main() {
	// scanf("%d", &n);
	n = 100000;
	b[0] = b[1] = 1;
	int m = 2;
	while(m <= n) {
		for(int j = m - 1, k = m; j >= 0; -- j, ++ k)
			b[k] = b[j];
		b[m] = -b[m];
		m *= 2;
	}
	pos.push_back(1);
	while(pos.back() <= n)
		pos.push_back(pos.back() * 2 + 1);
	for(scanf("%d", &T); T --; ) {
		scanf("%d", &n);
		for(int i = 1; i <= n; ++ i)
			scanf("%d", &a[i]);
		// for(int i = 1; i <= n; ++ i)
			// cerr << b[i] << " ";
		// cerr << endl;
		int p = 0;
		while(pos[p] <= n)
			++ p;
		-- p;
		for(int i = 0; i <= n + 1; ++ i)
			f[i][0] = f[i][1] = 1e9;
		f[n][0] = f[n][1] = 0;
		int ans = 0;
		for(int i = n; i >= 1; -- i) {
			// cerr << i << " " << i + 1 << " " << lb(i + 1) << endl;
			if(pd(i)) { // can change
			continue;
			} else ans += (a[i] != b[i]);
		}
		printf("%d\n", ans);
	}
}

詳細信息

Test #1:

score: 100
Accepted
time: 3ms
memory: 6152kb

input:

3
4
1 1 1 1
2
1 -1
5
-1 1 1 1 -1

output:

2
0
2

result:

ok 3 number(s): "2 0 2"

Test #2:

score: -100
Wrong Answer
time: 5ms
memory: 6788kb

input:

3
27354
-1 -1 1 -1 1 1 1 1 -1 -1 1 1 -1 1 1 -1 -1 1 1 -1 -1 -1 -1 -1 -1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 -1 1 1 1 -1 -1 1 1 1 1 -1 -1 1 -1 1 -1 1 -1 1 1 -1 1 1 1 -1 1 1 1 1 -1 -1 -1 -1 1 -1 -1 1 1 1 1 -1 -1 1 1 1 1 1 1 -1 1 1 -1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 1 -1 -1 -1 1 1 1 -1 1 -1 -1 -1 ...

output:

13612
28050
7281

result:

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