QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#775452#9745. 递增序列bluejellyfishWA 43ms3616kbC++231.5kb2024-11-23 15:57:292024-11-23 15:57:29

Judging History

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

  • [2024-11-23 15:57:29]
  • 评测
  • 测评结果:WA
  • 用时:43ms
  • 内存:3616kb
  • [2024-11-23 15:57:29]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
#define x first
#define y second
const int mod = 1e9 + 7;
void miss() {
	int n,k;
	cin >> n >> k;
	vector<int>ai(n + 1),fg(66,-1);
	for(int i = 1; i <= n; i++) {
		cin >> ai[i];
	}
	auto check =[&] (int qwq,int qaq) -> bool {
		for(int i = 61; ~i; i--) {
			if((((qwq >> i) & 1) != ((qaq >> i) & 1))) {
				if((qwq >> i) & 1) {
					if(fg[i + 1] == 1) return 0;
					else fg[i + 1] = 0;
				}else {
					if(!fg[i + 1]) return 0;
					else fg[i + 1] = 1;
				}
				return 1;
			} 
		}
	};
	for(int i = 2; i <= n; i++) {
		if(!check(ai[i],ai[i - 1])) {
			cout << "0\n";
			return;
		}
	}
	int zlm = 1;
	for(int i = 62; i >= 0; i--) {
		if((1ll << i) <= k) {
			zlm = i + 3;
			break;
		}
	}
	if(zlm > 63) zlm = 63;
	auto dfs =[&] (auto self,int sum,int tot) -> int {
		if(tot < 0) return 0;
		if(!sum) return 1;
		int ans = 0;
		if(fg[sum] == -1) {
			ans += self(self,sum - 1,tot - (1ll << (sum - 1)));
			if(tot >= (1ll << (sum - 1))) {
				int x = 1;
				for(int i = sum - 1; i >= 1; i--) {
					if(fg[i] == -1) x <<= 1;
				}
				ans += x;
			}else ans += self(self,sum - 1,tot);
		}else if(fg[sum]) ans += self(self,sum - 1,tot - (1ll << (sum - 1)));
		else ans += self(self,sum - 1,tot);
		return ans;
	};
	cout << dfs(dfs,zlm,k) << endl;
}
signed main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	int T = 1;
    cin >> T;
	while(T--) miss();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

1
4 17
3 2 5 16

output:

4

result:

ok single line: '4'

Test #2:

score: -100
Wrong Answer
time: 43ms
memory: 3616kb

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
180143985...

result:

wrong answer 124th lines differ - expected: '0', found: '9299935993640239'