QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#441861#8174. Set ConstructionHKOI0#RE 1ms3784kbC++141.0kb2024-06-14 20:06:022024-06-14 20:06:03

Judging History

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

  • [2024-06-14 20:06:03]
  • 评测
  • 测评结果:RE
  • 用时:1ms
  • 内存:3784kb
  • [2024-06-14 20:06:02]
  • 提交

answer

#include <bits/stdc++.h>
#define int long long
#define all(a) begin(a), end(a)
using namespace std;


void solve() {
	int n, m; cin >> n >> m;

	vector<int> ans;
	ans.push_back(0); ans.push_back((1LL << n) - 1);
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			int val = 0;
			for (int k = i; k <= j; k++) {
				val += 1LL << k;
			}
			for (int k = i - 2; k >= 0; k--) {
				val += 1LL << k;
			}
			if (val == (1LL << n) - 1) continue;
			if (ans.size() < m) {
				ans.push_back(val);
			}
		}
	}
	sort(ans.begin(), ans.end());
	for (auto x : ans) {
		cout << x << ' ';
	}
	cout << '\n';
	assert(ans.size() == m);
	assert(ans[0] == 0);
	assert(ans.back() == (1LL << n) - 1);
	for (int i = 0; i < ans.size(); i++) {
		for (int j = 0; j < ans.size(); j++) {
			assert(binary_search(all(ans), ans[i] & ans[j]));
			assert(binary_search(all(ans), ans[i] | ans[j]));
		}
	}
}

int32_t main(){
#ifndef LOCAL
	cin.tie(0)->sync_with_stdio(false);
#endif
	int t = 1;
	cin >> t;
	while (t--) {
		solve();
	}
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

3
3 5
4 8
60 2

output:

0 1 2 3 7 
0 1 2 3 6 7 14 15 
0 1152921504606846975 

result:

ok AC

Test #2:

score: -100
Runtime Error

input:

30
6 2
6 3
6 4
6 5
6 6
6 7
6 8
6 9
6 10
6 11
6 12
6 13
6 14
6 15
6 16
6 17
6 18
6 19
6 20
6 21
7 2
7 3
7 4
7 5
7 6
7 7
7 8
7 9
7 10
7 11

output:


result: