# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
118713 | 2019-06-19T13:52:12 Z | sebinkim | 수열 (BOI14_sequence) | C++14 | 100 ms | 1784 KB |
#include <bits/stdc++.h> using namespace std; typedef long long ll; ll n; ll f(vector <ll> &X, ll d, bool z) { if(d > 14) return -1; vector <ll> Y; ll i, j, k, y, ret = 1e18; if(X.size() == 1){ if(z && X[0] == 0) return 1; else if(z && X[0] == 1) return 10; ret = 0; for(i=1; i<10; i++){ if(X[0] & (1ll << i)){ ret = ret * 10 + i; if(X[0] & 1ll){ ret *= 10; X[0] -= 1; } } } return ret; } for(i=0; i<10; i++){ Y.clear(); y = 0; for(j=0, k=i; j<X.size(); j++, k=++k%10){ if(k == 0 && j) Y.push_back(y), y = 0; if(X[j] & (1ll << k)) y |= X[j] - (1ll << k); else y |= X[j]; } Y.push_back(y); if(X == Y) continue; k = f(Y, d + 1, Y[0] != 0 || (z && i == 0)) * 10 + i; if(k >= 0) ret = min(ret, k); } return ret; } int main() { vector <ll> X; ll i, x; scanf("%lld", &n); for(i=0; i<n; i++){ scanf("%lld", &x); X.push_back(1ll << x); } printf("%lld\n", f(X, 1, 1)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 2 ms | 256 KB | Output is correct |
12 | Correct | 2 ms | 356 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 3 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 512 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 256 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 256 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 3 ms | 256 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 3 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 256 KB | Output is correct |
19 | Correct | 2 ms | 384 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 256 KB | Output is correct |
22 | Correct | 3 ms | 256 KB | Output is correct |
23 | Correct | 3 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 11 ms | 512 KB | Output is correct |
3 | Correct | 11 ms | 512 KB | Output is correct |
4 | Correct | 9 ms | 512 KB | Output is correct |
5 | Correct | 9 ms | 512 KB | Output is correct |
6 | Correct | 6 ms | 512 KB | Output is correct |
7 | Correct | 43 ms | 1656 KB | Output is correct |
8 | Correct | 39 ms | 1020 KB | Output is correct |
9 | Correct | 58 ms | 1656 KB | Output is correct |
10 | Correct | 59 ms | 1656 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 48 ms | 1020 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 256 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 59 ms | 1784 KB | Output is correct |
12 | Correct | 85 ms | 1656 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 3 ms | 256 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 384 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 3 ms | 384 KB | Output is correct |
20 | Correct | 3 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 2 ms | 256 KB | Output is correct |
23 | Correct | 3 ms | 256 KB | Output is correct |
24 | Correct | 2 ms | 256 KB | Output is correct |
25 | Correct | 3 ms | 256 KB | Output is correct |
26 | Correct | 3 ms | 384 KB | Output is correct |
27 | Correct | 11 ms | 512 KB | Output is correct |
28 | Correct | 11 ms | 540 KB | Output is correct |
29 | Correct | 9 ms | 512 KB | Output is correct |
30 | Correct | 10 ms | 512 KB | Output is correct |
31 | Correct | 7 ms | 512 KB | Output is correct |
32 | Correct | 42 ms | 1528 KB | Output is correct |
33 | Correct | 39 ms | 1020 KB | Output is correct |
34 | Correct | 57 ms | 1656 KB | Output is correct |
35 | Correct | 58 ms | 1656 KB | Output is correct |
36 | Correct | 73 ms | 1656 KB | Output is correct |
37 | Correct | 96 ms | 1656 KB | Output is correct |
38 | Correct | 59 ms | 1052 KB | Output is correct |
39 | Correct | 100 ms | 1680 KB | Output is correct |
40 | Correct | 99 ms | 1656 KB | Output is correct |