QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#441854 | #8174. Set Construction | HKOI0# | RE | 1ms | 3544kb | C++14 | 1002b | 2024-06-14 20:01:01 | 2024-06-14 20:01:03 |
Judging History
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;
}
if (val == (1LL << n) - 1) continue;
if (ans.size() < m) {
ans.push_back(val);
}
}
}
sort(ans.begin(), ans.end());
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]));
}
}
for (auto x : ans) {
cout << x << ' ';
}
cout << '\n';
}
int32_t main(){
#ifndef LOCAL
cin.tie(0)->sync_with_stdio(false);
#endif
int t = 1;
cin >> t;
while (t--) {
solve();
}
}
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3544kb
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