Submission #940438

# Submission time Handle Problem Language Result Execution time Memory
940438 2024-03-07T09:16:34 Z vjudge1 Sequence (BOI14_sequence) C++17
34 / 100
1000 ms 201900 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];
bool mark[10000009][10], mark1[10000009][10];

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 178 ms 99644 KB Output is correct
2 Correct 167 ms 99312 KB Output is correct
3 Correct 166 ms 99412 KB Output is correct
4 Correct 172 ms 99388 KB Output is correct
5 Correct 166 ms 99412 KB Output is correct
6 Correct 167 ms 99408 KB Output is correct
7 Correct 173 ms 99668 KB Output is correct
8 Correct 166 ms 99320 KB Output is correct
9 Correct 199 ms 99432 KB Output is correct
10 Correct 170 ms 99448 KB Output is correct
11 Correct 165 ms 99328 KB Output is correct
12 Correct 178 ms 99296 KB Output is correct
13 Correct 170 ms 99412 KB Output is correct
14 Correct 171 ms 99412 KB Output is correct
15 Correct 172 ms 99324 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 165 ms 99308 KB Output is correct
2 Correct 166 ms 99680 KB Output is correct
3 Correct 164 ms 99296 KB Output is correct
4 Correct 169 ms 99296 KB Output is correct
5 Correct 171 ms 99328 KB Output is correct
6 Correct 164 ms 99448 KB Output is correct
7 Correct 166 ms 99308 KB Output is correct
8 Correct 169 ms 99312 KB Output is correct
9 Correct 169 ms 99548 KB Output is correct
10 Correct 167 ms 99420 KB Output is correct
11 Execution timed out 1028 ms 99560 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 168 ms 99300 KB Output is correct
2 Correct 169 ms 99408 KB Output is correct
3 Correct 547 ms 99412 KB Output is correct
4 Correct 172 ms 99352 KB Output is correct
5 Correct 611 ms 99636 KB Output is correct
6 Correct 170 ms 99472 KB Output is correct
7 Correct 284 ms 99592 KB Output is correct
8 Correct 559 ms 99804 KB Output is correct
9 Correct 426 ms 99896 KB Output is correct
10 Correct 480 ms 99896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 166 ms 99280 KB Output is correct
2 Correct 168 ms 99412 KB Output is correct
3 Correct 172 ms 99448 KB Output is correct
4 Correct 168 ms 99276 KB Output is correct
5 Runtime error 341 ms 201900 KB Execution killed with signal 11
6 Halted 0 ms 0 KB -