This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#define file_io freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
#define fast_io ios::sync_with_stdio(false);cin.tie(0);
#define what(x) cerr << #x << " is " << x << '\n';
#define kill(x) {cout << x << '\n'; return 0;}
#define all(x) (x).begin(), (x).end()
#define pii pair<int, int>
#define pb push_back
#define ll long long
#define F first
#define S second
const ll inf = 1e16, mod = 1e9 + 7, delta = 1e9 + 9, SQ = 450, P = 6065621;
using namespace std;
const int N = 1e7 + 10, LG = 20;
bitset<10> mark[N], f;
vector<int> v;
int a[N];
int main () {
  fast_io;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    cin >> a[i];
  
  for (int i = 1; i < N; i++) {
    int x = i;
    while (x > 0) {
      mark[i][x % 10] = true;
      x /= 10;
    }
  }
  for (int i = 1; i < N; i++) {
    bool b = true;
    for (int j = i; j <= n + i - 1; j++) {
      if (!mark[j][a[j - i + 1]]) {b = false; break;}    
    }
    if (b) kill(i);
  } 
  return 0;
}
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict  | Execution time | Memory | Grader output | 
|---|
| Fetching results... |