Submission #940407

# Submission time Handle Problem Language Result Execution time Memory
940407 2024-03-07T08:55:49 Z vjudge1 Sequence (BOI14_sequence) C++17
0 / 100
148 ms 82772 KB
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#include "debug.h"
#else
#define debug(...) 0
#endif

#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2")

#define pb push_back
#define i2 array<int, 2>
#define ll long long

const int N = 1e6 + 4;

int k, b[N], f[N][10];

bool have(int x, int d) {
    while (x) {
        if (x % 10 == d) {
            return 1;
        }
        x /= 10;
    }
    return 0;
}

void solve() {
    cin >> k;
    for (int i = 0; i < k; i++) {
        cin >> b[i];
    }

    int n = 1;
    while (1) {
        bool ok = 1;
        if (have(n + k - 1, b[k - 1])) {
            for (int j = 0; j < k; j++) {
                ok &= f[n + j][b[j]];
                if (ok == 0) {
                    break;
                }
            }
            if (ok) {
                cout << n << '\n';
            }
        }
        n++;
    }
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);

    for (int i = 1; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            f[i][j] = have(i, j);
        }
    }

    int t = 1;
    // cin >> t;
    while (t--) {
        solve();
    }

    return 0;
}

# Verdict Execution time Memory Grader output
1 Runtime error 144 ms 80044 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 128 ms 80296 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 148 ms 82772 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 128 ms 80212 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -