///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;
break;
}
}
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
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
250 ms |
115636 KB |
Output is correct |
2 |
Correct |
238 ms |
114800 KB |
Output is correct |
3 |
Correct |
234 ms |
113892 KB |
Output is correct |
4 |
Correct |
236 ms |
114872 KB |
Output is correct |
5 |
Correct |
242 ms |
115528 KB |
Output is correct |
6 |
Correct |
237 ms |
114468 KB |
Output is correct |
7 |
Correct |
238 ms |
114616 KB |
Output is correct |
8 |
Correct |
242 ms |
114704 KB |
Output is correct |
9 |
Correct |
254 ms |
113848 KB |
Output is correct |
10 |
Correct |
235 ms |
115112 KB |
Output is correct |
11 |
Correct |
241 ms |
113868 KB |
Output is correct |
12 |
Correct |
244 ms |
113848 KB |
Output is correct |
13 |
Correct |
235 ms |
114152 KB |
Output is correct |
14 |
Correct |
236 ms |
115452 KB |
Output is correct |
15 |
Correct |
245 ms |
114368 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
239 ms |
115436 KB |
Output is correct |
2 |
Correct |
236 ms |
114880 KB |
Output is correct |
3 |
Correct |
235 ms |
115072 KB |
Output is correct |
4 |
Correct |
237 ms |
113848 KB |
Output is correct |
5 |
Correct |
237 ms |
114160 KB |
Output is correct |
6 |
Correct |
235 ms |
114364 KB |
Output is correct |
7 |
Correct |
237 ms |
115388 KB |
Output is correct |
8 |
Correct |
236 ms |
113660 KB |
Output is correct |
9 |
Correct |
246 ms |
114668 KB |
Output is correct |
10 |
Correct |
237 ms |
114868 KB |
Output is correct |
11 |
Execution timed out |
1078 ms |
115680 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
247 ms |
114080 KB |
Output is correct |
2 |
Correct |
241 ms |
115644 KB |
Output is correct |
3 |
Correct |
740 ms |
114868 KB |
Output is correct |
4 |
Correct |
243 ms |
113844 KB |
Output is correct |
5 |
Correct |
832 ms |
115684 KB |
Output is correct |
6 |
Correct |
251 ms |
114968 KB |
Output is correct |
7 |
Correct |
388 ms |
114344 KB |
Output is correct |
8 |
Correct |
749 ms |
114364 KB |
Output is correct |
9 |
Correct |
547 ms |
114364 KB |
Output is correct |
10 |
Correct |
638 ms |
114036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
241 ms |
113944 KB |
Output is correct |
2 |
Correct |
236 ms |
114952 KB |
Output is correct |
3 |
Correct |
237 ms |
113660 KB |
Output is correct |
4 |
Correct |
237 ms |
114708 KB |
Output is correct |
5 |
Incorrect |
267 ms |
115128 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |