Submission #940443

# Submission time Handle Problem Language Result Execution time Memory
940443 2024-03-07T09:21:34 Z vjudge1 Sequence (BOI14_sequence) C++17
34 / 100
971 ms 79188 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;

const int N = 1e5 + 10;

int n, a[N];
bitset<11> mark[10000009], mark1[10000009];

int main() {
    ios:: sync_with_stdio(0), cin.tie(0);
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int w = 1; w <= 10000000; w++) {
        if (10000000 < w) {
            string s = to_string(w);
            for (auto e : s)
                mark1[w - 10000000][e - '0'] = true;
        }
        string s = to_string(w);
        for (auto e : s)
            mark[w][e - '0'] = true;
    }
    for (int w = 1; w <= 10000000; w++) {
        int cnt = w;
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (i) cnt++;
            if (!mark[cnt][a[i]]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << w << '\n';
            return 0;
        }
    }
    for (int w = 1000001; w <= 20000000; w++) {
        int cnt = w;
        bool flag = true;
        for (int i = 0; i < n; i++) {
            if (i) cnt++;
            if (!mark1[cnt - 1000000][a[i]]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << w << '\n';
            return 0;
        }
    }
    cout << -1 << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 187 ms 78660 KB Output is correct
2 Correct 194 ms 78564 KB Output is correct
3 Correct 189 ms 78544 KB Output is correct
4 Correct 188 ms 78676 KB Output is correct
5 Correct 188 ms 78608 KB Output is correct
6 Correct 194 ms 78672 KB Output is correct
7 Correct 188 ms 78584 KB Output is correct
8 Correct 191 ms 78676 KB Output is correct
9 Correct 188 ms 78704 KB Output is correct
10 Correct 193 ms 78512 KB Output is correct
11 Correct 188 ms 78676 KB Output is correct
12 Correct 185 ms 78488 KB Output is correct
13 Correct 186 ms 78680 KB Output is correct
14 Correct 186 ms 78672 KB Output is correct
15 Correct 186 ms 78644 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 193 ms 78552 KB Output is correct
2 Correct 185 ms 78676 KB Output is correct
3 Correct 186 ms 78628 KB Output is correct
4 Correct 187 ms 78608 KB Output is correct
5 Correct 191 ms 78708 KB Output is correct
6 Correct 192 ms 78672 KB Output is correct
7 Correct 189 ms 78524 KB Output is correct
8 Correct 189 ms 78636 KB Output is correct
9 Correct 190 ms 78536 KB Output is correct
10 Correct 202 ms 78564 KB Output is correct
11 Incorrect 971 ms 79088 KB Output isn't correct
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 190 ms 78676 KB Output is correct
2 Correct 197 ms 78672 KB Output is correct
3 Correct 445 ms 78764 KB Output is correct
4 Correct 193 ms 78676 KB Output is correct
5 Correct 461 ms 78764 KB Output is correct
6 Correct 190 ms 78672 KB Output is correct
7 Correct 263 ms 79188 KB Output is correct
8 Correct 433 ms 78896 KB Output is correct
9 Correct 348 ms 78932 KB Output is correct
10 Correct 382 ms 79184 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 194 ms 78704 KB Output is correct
2 Correct 189 ms 78712 KB Output is correct
3 Correct 190 ms 78576 KB Output is correct
4 Correct 195 ms 78616 KB Output is correct
5 Incorrect 248 ms 78932 KB Output isn't correct
6 Halted 0 ms 0 KB -