Submission #865573

# Submission time Handle Problem Language Result Execution time Memory
865573 2023-10-24T11:01:50 Z azimanov Sequence (BOI14_sequence) C++17
9 / 100
1000 ms 39688 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

bool getbit(int mask, int bit) {
    return mask & (1 << bit);
}

const int N = 1e7 + 10;
const int K = 1e5 + 10;
int b[K];
int mask[N];

void init() {
    mask[0] = (1 << 0);
    for (int i = 1; i <= N - 1; i++) {
        for (int j = i; j >= 1; j /= 10) {
            mask[i] |= (1 << (j % 10));
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    init();

    int k;
    cin >> k;
    for (int i = 1; i <= k; i++) {
        cin >> b[i];
    }
    if (k >= 1000 + 1) {
        cout << "1\n";
        return 0;
    }
    int ans = -1;
    for (int n = 1; n + k - 1 <= N - 1; n++) {
        bool ok = true;
        for (int i = 1; i <= k; i++) {
            ok &= getbit(mask[n + i - 1], b[i]);
        }
        if (ok) {
            ans = n;
            break;
        }
    }
    assert(ans != -1);
    cout << ans << "\n";

#ifdef LOCAL
    cout << "\nTime elapsed: " << double(clock()) / CLOCKS_PER_SEC << " s.\n";
#endif
}
# Verdict Execution time Memory Grader output
1 Correct 79 ms 39508 KB Output is correct
2 Correct 79 ms 39412 KB Output is correct
3 Correct 79 ms 39444 KB Output is correct
4 Correct 79 ms 39436 KB Output is correct
5 Correct 83 ms 39540 KB Output is correct
6 Correct 79 ms 39564 KB Output is correct
7 Correct 79 ms 39508 KB Output is correct
8 Correct 80 ms 39336 KB Output is correct
9 Correct 80 ms 39504 KB Output is correct
10 Correct 79 ms 39392 KB Output is correct
11 Correct 84 ms 39508 KB Output is correct
12 Correct 79 ms 39448 KB Output is correct
13 Correct 80 ms 39424 KB Output is correct
14 Correct 79 ms 39372 KB Output is correct
15 Correct 80 ms 39472 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 79 ms 39496 KB Output is correct
2 Correct 82 ms 39556 KB Output is correct
3 Correct 80 ms 39504 KB Output is correct
4 Correct 80 ms 39508 KB Output is correct
5 Correct 84 ms 39688 KB Output is correct
6 Correct 79 ms 39412 KB Output is correct
7 Correct 84 ms 39504 KB Output is correct
8 Correct 79 ms 39508 KB Output is correct
9 Correct 82 ms 39444 KB Output is correct
10 Correct 79 ms 39504 KB Output is correct
11 Execution timed out 1064 ms 39400 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 80 ms 39508 KB Output is correct
2 Incorrect 81 ms 39504 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 79 ms 39504 KB Output is correct
2 Correct 79 ms 39492 KB Output is correct
3 Correct 79 ms 39508 KB Output is correct
4 Correct 79 ms 39504 KB Output is correct
5 Incorrect 80 ms 39648 KB Output isn't correct
6 Halted 0 ms 0 KB -