/// ITNOG
#include <bits/stdc++.h>
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
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;
string a;
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
for(int i = 1; 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){
int x; cin >> x;
a += ((char) x + '0');
}
for (int i = 1; i < N; ++ i){
bool ok = true;
for (int j = 0; j < n; ++ j){
if (!mark[i+j][a[j] - '0']){
ok = false;
}
}
if (ok){
cout << i;
return 0;
}
}
cout << -1;
}
// Yesterday is history
// Tomorrow is a mystery
// but today is a gift
// That is why it is called the present
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
249 ms |
114360 KB |
Output is correct |
2 |
Correct |
244 ms |
114432 KB |
Output is correct |
3 |
Correct |
237 ms |
114948 KB |
Output is correct |
4 |
Correct |
241 ms |
115380 KB |
Output is correct |
5 |
Correct |
240 ms |
114808 KB |
Output is correct |
6 |
Correct |
238 ms |
114180 KB |
Output is correct |
7 |
Correct |
242 ms |
114748 KB |
Output is correct |
8 |
Correct |
247 ms |
113944 KB |
Output is correct |
9 |
Correct |
236 ms |
113940 KB |
Output is correct |
10 |
Correct |
237 ms |
115232 KB |
Output is correct |
11 |
Correct |
236 ms |
114612 KB |
Output is correct |
12 |
Correct |
246 ms |
115848 KB |
Output is correct |
13 |
Correct |
239 ms |
114668 KB |
Output is correct |
14 |
Correct |
239 ms |
115124 KB |
Output is correct |
15 |
Correct |
242 ms |
114400 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
271 ms |
115024 KB |
Output is correct |
2 |
Correct |
247 ms |
114880 KB |
Output is correct |
3 |
Correct |
235 ms |
114212 KB |
Output is correct |
4 |
Correct |
236 ms |
114616 KB |
Output is correct |
5 |
Correct |
240 ms |
113964 KB |
Output is correct |
6 |
Correct |
242 ms |
115180 KB |
Output is correct |
7 |
Correct |
250 ms |
114108 KB |
Output is correct |
8 |
Correct |
239 ms |
115128 KB |
Output is correct |
9 |
Correct |
237 ms |
113900 KB |
Output is correct |
10 |
Correct |
239 ms |
115148 KB |
Output is correct |
11 |
Execution timed out |
1043 ms |
114360 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
235 ms |
113936 KB |
Output is correct |
2 |
Execution timed out |
1016 ms |
115064 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
241 ms |
115048 KB |
Output is correct |
2 |
Correct |
236 ms |
114472 KB |
Output is correct |
3 |
Correct |
237 ms |
114136 KB |
Output is correct |
4 |
Correct |
242 ms |
114112 KB |
Output is correct |
5 |
Execution timed out |
1044 ms |
114100 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |