QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#296810#7940. Impossible Numbersmendicillin2#WA 1ms3792kbC++142.6kb2024-01-03 17:18:452024-01-03 17:18:45

Judging History

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

  • [2024-01-03 17:18:45]
  • 评测
  • 测评结果:WA
  • 用时:1ms
  • 内存:3792kb
  • [2024-01-03 17:18:45]
  • 提交

answer

#include <bits/stdc++.h>

#define LL long long
#define ull unsigned long long
#define F(i, j, k) for (int i = j; i <= k; ++i)
#define DF(i, j, k) for (int i = j; i >= k; --i)

using namespace std;

template <typename T> inline void read(T &n) {
    T w = 1;
    n = 0;
    char ch = getchar();
    while (!isdigit(ch) && ch != EOF) {
        if (ch == '-') w = -1;
        ch = getchar();
    }
    while (isdigit(ch) && ch != EOF) {
        n = (n << 3) + (n << 1) + (ch & 15);
        ch = getchar();
    }
    n *= w;
}

template <typename T> inline void write(T x) {
    T l = 0;
    ull y = 0;
    if (!x) { putchar(48); return; }
    if (x < 0) { x = -x; putchar('-'); }
    while (x) { y = y * 10 + x % 10; x /= 10; ++l; }
    while (l) { putchar(y % 10 + 48); y /= 10; --l; }
}

template <typename T> inline void writes(T x) {
    write(x);
    putchar(' ');
}

template <typename T> inline void writeln(T x) {
    write(x);
    puts("");
}

template <typename T> inline void checkmax(T &a, T b) { a = a > b ? a : b; }

template <typename T> inline void checkmin(T &a, T b) { a = a < b ? a : b; }

const int N = 100, K = 100, debug = 1;

int a[110][10], dp[1100], c[1100];

int now = 0, n, k;

inline void dfs(int x, vector <pair<int, int>> v) {
    if (v.empty()) return;
    if (x > now) {
        --k;
        F(i, 1, now) write(c[i]);
        if (k == 0) putchar('\n');
        else putchar(' ');
        if (k == 0) exit(0);
        return;
    }
    F(i, (x == 1) ? 1 : 0, 9) {
        vector <pair<int, int> > t;
        for (auto y : v) {
            int A = y.first, B = y.second;
            if ((A >> i) & 1) --B;
            if (now - x > B) t.emplace_back(A, B);
        }
        c[x] = i;
        dfs(x + 1, t);
    }
}

int main() {
    //freopen(".in", "r", stdin);
    //freopen(".out", "w", stdout);
    srand(time(0));
    if (debug) {
        n = N;
        k = K;
        F(i, 1, n)
            F(j, 1, 6) {
                int x; x = rand() % 10;
                a[i][x] = 1;
            }
    }
    else {
        read(n); read(k);
        F(i, 1, n)
            F(j, 1, 6) {
                int x; read(x);
                a[i][x] = 1;
            }
    }
    F(i, 0, (1 << 10) - 1) {
        F(k, 1, n) {
            int cur = 0;
            F(j, 0, 9)
                if ((i >> j) & 1)
                    cur |= a[k][j];
            dp[i] += cur;
        }
    }
    now = 0;
    while (k) {
        ++now;
        vector <pair<int, int> > v;
        F(i, 1, (1 << 10) - 1) if (now > dp[i]) v.emplace_back(i, dp[i]);
        dfs(1, v);
    }
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3792kb

input:

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

output:

11111111111111111111111111111111111 101111111111111111111111111111111111 110111111111111111111111111111111111 111011111111111111111111111111111111 111101111111111111111111111111111111 111110111111111111111111111111111111 111111011111111111111111111111111111 111111101111111111111111111111111111 11111...

result:

wrong answer 1st lines differ - expected: '33 34 35', found: '111111111111111111111111111111...1111111111111111111111181111111'