QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#284660#7940. Impossible Numbersucup-team055#WA 1ms3512kbC++231.8kb2023-12-16 14:18:162023-12-16 14:18:17

Judging History

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

  • [2023-12-17 13:41:15]
  • hack成功,自动添加数据
  • (/hack/501)
  • [2023-12-16 14:18:17]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3512kb
  • [2023-12-16 14:18:16]
  • 提交

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 {{1023, -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;
                if(--K == 0) {
                    cout << endl;
                    exit(0);
                }
                else cout << ' ';
                return;
            }
            int bit = 0;
            for(auto x : cond | views::keys) bit |= x;
            rep(c, first, 10) if(bit & 1 << c) {
                S.push_back(48 + c);
                dfs(0, d - 1, nx_cond(cond, c), dfs);
                S.pop_back();
            }
        };
        dfs(1, d, cond, dfs);
    }
}

詳細信息

Test #1:

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

input:

2 3
1 8 7 0 6 2
1 2 5 4 9 3

output:

33 34 35

result:

ok single line: '33 34 35'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3460kb

input:

1 10
1 5 2 2 6 4

output:

3 7 8 9 10 11 12 13 14 15

result:

ok single line: '3 7 8 9 10 11 12 13 14 15'

Test #3:

score: -100
Wrong Answer
time: 0ms
memory: 3456kb

input:

4 10
1 5 7 1 2 4
0 1 5 8 9 4
3 5 2 2 7 8
6 1 7 0 2 2

output:

33 66 99 330 331 332 333 334 335 336

result:

wrong answer 1st lines differ - expected: '33 66 99 133 166 199 233 266 299 303', found: '33 66 99 330 331 332 333 334 335 336'