QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#441981#8174. Set ConstructionHKOI0WA 1ms3548kbC++142.0kb2024-06-15 01:17:382024-06-15 01:17:38

Judging History

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

  • [2024-06-15 01:17:38]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3548kb
  • [2024-06-15 01:17:38]
  • 提交

answer

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

bool check_valid(int n, int m){
	return 2 <= n && 2 <= m && m <= n * (n + 1) / 2;
}

vector<int> f(int n, int m){
	assert(check_valid(n, m));
	if (m == 2) return {0, (1LL << n) - 1};
	if (m % 2 == 1) {
		if (check_valid(n - 2, (m - 1) / 2)) {
			vector<int> a = f(n - 2, (m - 1) / 2);
			for (auto& x : a) x = x * 4 + 1;
			int k = a.size(); for (int i = 0; i < k; i++) a.push_back(a[i] + 2);
			a.push_back(0);
			return a;
		} else if (check_valid(n - 1, m - 1)) {
			vector<int> a = f(n - 1, m - 1);
			for (auto& x : a) x = x * 2 + 1;
			a.push_back(0);
			return a;
		}
	} else {
		if (check_valid(n - 1, m / 2)) {
			vector<int> a = f(n - 1, m / 2);
			for (auto& x : a) x *= 2;
			int k = a.size();
			for (int i = 0; i < k; i++) a.push_back(a[i] + 1);
			return a;
		}
	}

	if (n == 5 && m == 15) {
		vector<int> A = f(2, 3);
		vector<int> B = f(3, 5);
		vector<int> c;
		for (auto a : A) {
			for (auto b : B) {
				c.push_back((a << 3) | b);
			}
		}
		return c;
	} else if (n == 4 && m == 9) {
		vector<int> A = f(2, 3);
		vector<int> B = f(2, 3);
		vector<int> c;
		for (auto a : A) {
			for (auto b : B) {
				c.push_back((a << 2) | b);
			}
		}
		return c;
	} else if (n == 3 && m == 5) {
		return {0, 1, 2, 3, 7};
	} else if (n == 2 && m == 3) {
		return {0, 1, 3};
	} else {
		assert(false);
	}
	return {};
}

void solve() {
	int n, m; cin >> n >> m;
	vector<int> ans = f(n, m);
	sort(all(ans));
	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: 0
Wrong Answer
time: 1ms
memory: 3548kb

input:

3
3 5
4 8
60 2

output:


result:

wrong output format Unexpected end of file - int64 expected