QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#760194#9745. 递增序列AgakissWA 46ms3664kbC++201.4kb2024-11-18 15:31:052024-11-18 15:31:09

Judging History

This is the latest submission verdict.

  • [2024-11-18 15:31:09]
  • Judged
  • Verdict: WA
  • Time: 46ms
  • Memory: 3664kb
  • [2024-11-18 15:31:05]
  • Submitted

answer

#include<bits/stdc++.h>
#define endl '\n'
#define i64 long long
#define pb push_back
#define pii std::pair<i64, i64>
const i64 N = 1e5 + 10;
const i64 H = 60;
i64 T, n, k;
i64 flag;
i64 res;
i64 a[N], p[N];
void check(i64 x, i64 y) {
	for (i64 i = H; i >= 0; i--)
		if ((x >> i & 1) != (y >> i & 1)) {
			if (p[i] < 2) {
				if (p[i] == x >> i & 1) p[i] = x >> i & 1;
				else flag = 0;
			}
			else
				p[i] = x >> i & 1;
			return;
		}
}
i64 calc(i64 x, i64 pos) {
	//std::cout << '[' << x << ',' << pos << ']' << endl;
	for (i64 i = H; i >= pos; i--)
		if (p[i] != 2)
			if ((x >> i & 1) != p[i]) return 0;
	i64 res = 1;
	for (i64 i = pos - 1; i >= 0; i--)
		if (p[i] == 2) res *= 2;
	//std::cout << '(' << res << ')' << endl;
	return res;
}
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0), std::cout.tie(0);
	std::cin >> T;
	while (T--) {
		flag = 1;
		for (i64 i = 0; i <= H; i++)
			p[i] = 2;
		std::cin >> n >> k;
		for (i64 i = 1; i <= n; i++)
			std::cin >> a[i];
		for (i64 i = 1; i < n; i++)
			check(a[i], a[i + 1]);
		/*for (i64 i = 20; i >= 0; i--)
			std::cout << p[i] << " ";
		std::cout << endl;*/
		if (!flag) { std::cout << 0 << endl; continue; }
		res = 0;
		for (i64 i = H; i >= 0; i--)
			if (k >> i & 1)
				res += calc(((k >> i) - 1) << i, i);
		res += calc(k, 0);
		std::cout << res << endl;
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Wrong Answer
time: 46ms
memory: 3600kb

input:

36156
2 732025001343805266
563399128172323734 55283226774627822
7 388099190813067712
564150557919527813 457487771983557281 332055400678110195 760833651510929158 785768483273197875 690506113272551236 463276585748519124
2 798714574862593347
426890163990834364 434764725667883272
1 414708220571820990
42...

output:

288230376151711744
0
432345564227567616
414708220571820991
716398192192370638
0
1949654914769744
0
0
0
811009189367843523
0
0
0
114457959388827198
36028797018963968
0
0
91540211282631659
0
694703231769895640
144115188075855872
0
0
0
0
432345564227567616
65333152962117911
753346372609875093
0
0
36458...

result:

wrong answer 30th lines differ - expected: '18014398509481984', found: '0'