제출 #940397

#제출 시각아이디문제언어결과실행 시간메모리
940397vjudge1수열 (BOI14_sequence)C++17
9 / 100
1063 ms100544 KiB
/// ITNOG
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#include <bits/stdc++.h>

using namespace std;

constexpr int MOD = 1e9 + 7, N = 1e7 + 8, M = 1e6, SQ = 600, INF = 1e9 + 8, LGN = 22, mod = 998244353, P = 131113;

bool mark[N][10];
int n, a[N];

int32_t main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  for (int i = 0; i < N; ++ i){
    string s = to_string(i);
    for (char ch : s){
      mark[i][ch-'0'] = true;
    }
  }
  cin >> n;
  for (int i = 0; i < N; ++ i){
    cin >> a[i];
  }
  for (int i = 1; i < N; ++ i){
    bool ok = true;
    for (int j = 0; j < n; ++ j){
      if (!mark[i+j][a[j]]){
        ok = false;
      }
    }
    if (ok){
      cout << i;
      return 0;
    }
  }
  cout << -1;
  return 0;
}

// Yesterday is history
// Tomorrow is a mystery
// but today is a gift
// That is why it is called the present
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...