# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
118686 | 2019-06-19T11:24:15 Z | imyujin | 수열 (BOI14_sequence) | C++14 | 199 ms | 1908 KB |
#include<stdio.h> #include<vector> using namespace std; #define MAXK 100005 const long long LINF=1ll<<58; int B[MAXK]; int cnt; bool p=false; long long f(vector<int> v){ vector<int> vv; long long ans=LINF; if(p){ printf("("); for(int i=0; i<v.size(); i++){ for(int j=9; j>=0; j--) printf("%d", (v[i]>>j)&1); printf("\n"); } } //if(cnt==100) return ans; //cnt++; bool b=true; for(int i=0; i<v.size(); i++) if(v[i]!=0) b=false; if(b) return 0; if(v.size()==1){ if(p)printf(")))))))))*\n"); ans=0; int j=1; while((v[0]&(1<<j))==0&&j<10) j++; if(j==10) return (v[0]&1)==0?0ll:10ll; else ans=j; if((v[0]&1)!=0) ans*=10; for(j++; j<10; j++) if((v[0]&(1<<j))!=0) ans=ans*10+j; if(p)printf("%lld*\n", ans); return ans; } for(int i=0; i<10; i++){ bool a=true; for(int j=0; j<v.size(); j++) if(v[j]!=(1<<((i+j)%10))&&v[j]!=0) a=false; if(a){ if(p)printf("))))))))\n"); return i==0&&(v[0]&1)!=0?10ll:(long long)i; } } for(int i=0; i<10; i++){ int k=0; vv.clear(); bool a=false; for(int j=0; j<v.size(); j++){ if(j==0||(i+j)%10==0) vv.push_back(0); vv[k]|=(v[j]-(v[j]&(1<<((i+j)%10)))); if(v[j]&(1<<((i+j)%10))) a=true; if((i+j)%10==9) k++; } if(a||vv.size()<v.size()) ans=min(ans, f(vv)*10+i); if(p){ printf("\n"); for(int i=0; i<v.size(); i++){ for(int j=9; j>=0; j--) printf("%d", (v[i]>>j)&1); printf("\n"); } printf("%d[%lld]\n", i, ans); } } if(p){ printf("\n"); for(int i=0; i<v.size(); i++){ for(int j=9; j>=0; j--) printf("%d", (v[i]>>j)&1); printf("\n"); } printf(")%lld\n", ans); } return ans; } int main(){ int K; vector<int> v; scanf("%d", &K); for(int i=0; i<K; i++) scanf("%d", B+i); for(int i=0; i<K; i++) v.push_back(1<<B[i]); printf("%lld", f(v)); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 384 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 | 256 KB | Output is correct |
6 | Correct | 2 ms | 256 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 256 KB | Output is correct |
10 | Correct | 4 ms | 384 KB | Output is correct |
11 | Correct | 3 ms | 384 KB | Output is correct |
12 | Correct | 2 ms | 384 KB | Output is correct |
13 | Correct | 2 ms | 256 KB | Output is correct |
14 | Correct | 4 ms | 384 KB | Output is correct |
15 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 256 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 256 KB | Output is correct |
5 | Correct | 2 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 3 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 256 KB | Output is correct |
11 | Correct | 4 ms | 256 KB | Output is correct |
12 | Correct | 4 ms | 256 KB | Output is correct |
13 | Correct | 3 ms | 384 KB | Output is correct |
14 | Correct | 2 ms | 384 KB | Output is correct |
15 | Correct | 2 ms | 256 KB | Output is correct |
16 | Correct | 4 ms | 256 KB | Output is correct |
17 | Correct | 4 ms | 256 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 3 ms | 384 KB | Output is correct |
20 | Correct | 4 ms | 384 KB | Output is correct |
21 | Correct | 2 ms | 384 KB | Output is correct |
22 | Correct | 3 ms | 256 KB | Output is correct |
23 | Correct | 4 ms | 384 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 14 ms | 384 KB | Output is correct |
3 | Correct | 15 ms | 512 KB | Output is correct |
4 | Correct | 14 ms | 384 KB | Output is correct |
5 | Correct | 13 ms | 384 KB | Output is correct |
6 | Correct | 11 ms | 384 KB | Output is correct |
7 | Correct | 86 ms | 1276 KB | Output is correct |
8 | Correct | 54 ms | 1020 KB | Output is correct |
9 | Correct | 120 ms | 1656 KB | Output is correct |
10 | Correct | 119 ms | 1656 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 3 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 92 ms | 1020 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 1 ms | 256 KB | Output is correct |
8 | Correct | 2 ms | 256 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 3 ms | 384 KB | Output is correct |
11 | Correct | 121 ms | 1784 KB | Output is correct |
12 | Correct | 117 ms | 1904 KB | Output is correct |
13 | Correct | 2 ms | 384 KB | Output is correct |
14 | Correct | 4 ms | 384 KB | Output is correct |
15 | Correct | 3 ms | 384 KB | Output is correct |
16 | Correct | 3 ms | 256 KB | Output is correct |
17 | Correct | 2 ms | 384 KB | Output is correct |
18 | Correct | 2 ms | 384 KB | Output is correct |
19 | Correct | 4 ms | 256 KB | Output is correct |
20 | Correct | 3 ms | 256 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 | 3 ms | 384 KB | Output is correct |
25 | Correct | 4 ms | 384 KB | Output is correct |
26 | Correct | 3 ms | 256 KB | Output is correct |
27 | Correct | 14 ms | 512 KB | Output is correct |
28 | Correct | 14 ms | 384 KB | Output is correct |
29 | Correct | 14 ms | 640 KB | Output is correct |
30 | Correct | 14 ms | 512 KB | Output is correct |
31 | Correct | 12 ms | 384 KB | Output is correct |
32 | Correct | 86 ms | 1404 KB | Output is correct |
33 | Correct | 54 ms | 1020 KB | Output is correct |
34 | Correct | 120 ms | 1784 KB | Output is correct |
35 | Correct | 121 ms | 1864 KB | Output is correct |
36 | Correct | 148 ms | 1404 KB | Output is correct |
37 | Correct | 199 ms | 1784 KB | Output is correct |
38 | Correct | 117 ms | 1276 KB | Output is correct |
39 | Correct | 198 ms | 1908 KB | Output is correct |
40 | Correct | 198 ms | 1900 KB | Output is correct |