QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#284639 | #7940. Impossible Numbers | ucup-team055# | WA | 1ms | 3456kb | C++23 | 1.6kb | 2023-12-16 14:13:39 | 2023-12-16 14:13:41 |
Judging History
你现在查看的是最新测评结果
- [2023-12-17 13:41:15]
- hack成功,自动添加数据
- (/hack/501)
- [2023-12-16 17:44:29]
- hack成功,自动添加数据
- (//qoj.ac/hack/496)
- [2023-12-16 14:13:39]
- 提交
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = LLONG_MAX / 4;
#define rep(i, a, b) for(ll i = a; i < b; i++)
#define all(a) begin(a), end(a)
template<class T> bool chmin(T& a, T b) { if(a <= b) return 0; a = b; return 1; }
template<class T> bool chmax(T& a, T b) { if(a >= b) return 0; a = b; return 1; }
int main() {
cin.tie(0)->sync_with_stdio(0);
int N, K;
cin >> N >> K;
vector<int> cnt(1 << 10);
rep(i, 0, N) {
int bit = 0;
rep(j, 0, 6) {
int a;
cin >> a;
bit |= 1 << a;
}
rep(j, 0, 1 << 10) if(j & bit) cnt[j]++;
}
string S;
for(int d = 1; ; d++) {
vector<pair<int16_t, int16_t>> cond;
rep(bit, 0, 1 << 10) cond.emplace_back(bit, cnt[bit]);
auto nx_cond = [&](vector<pair<int16_t, int16_t>> cond, int c) -> vector<pair<int16_t, int16_t>> {
c = 1 << c;
for(auto& [key, val] : cond) if(key & c) if(val-- == 0) return {{0, -1}};
return cond;
};
auto dfs = [&](bool first, int16_t d, vector<pair<int16_t, int16_t>> cond, auto dfs) -> void {
erase_if(cond, [&](pair<int16_t, int16_t> x) { return x.second >= d; });
if(cond.empty()) return;
if(d == 0) {
cout << S << '\n';
if(--K == 0) exit(0);
return;
}
rep(c, first, 10) {
S.push_back(48 + c);
dfs(0, d - 1, nx_cond(cond, c), dfs);
S.pop_back();
}
};
dfs(1, d, cond, dfs);
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 1ms
memory: 3456kb
input:
2 3 1 8 7 0 6 2 1 2 5 4 9 3
output:
33 34 35
result:
wrong answer 1st lines differ - expected: '33 34 35', found: '33'