# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
824067 | 2023-08-13T12:38:18 Z | Amylopectin | Boarding Passes (BOI22_passes) | C++14 | 2000 ms | 50128 KB |
#include <stdio.h> #include <iostream> #include <vector> #include <string.h> #include <stdlib.h> using namespace std; const int mxn = 1e6 + 10; vector<int> ar[mxn] = {},cli[mxn] = {}; double avinv[mxn] = {},fst[mxn] = {},ami = -1,dp[mxn] = {}; char s[mxn] = {}; int n,u[mxn] = {},alp[mxn] = {}; int re(int cn,int dep,int cru,double cva) { int i,j,cm,fn,fm,fru,fva,cfr; dep = 1; double cmi = 0; if(dp[cn] != -1) { return dp[cn]; } // if(dep == cru) // { // if(ami == -1) // { // ami = cva; // } // else // { // ami = min(cva,ami); // } // return 0; // } for(i=0; i<cru; i++) { if((1<<i) & cn) { cfr = cn - (1<<i); re(cfr,1,cru,0); cli[dep-1].clear(); for(j=0; j<n; j++) { if((1<<(alp[s[j] - 'A' + 1])) & cfr) { cli[dep-1].push_back(j); } } // if(u[i] == 1) // { // continue; // } // u[i] = 1; cli[dep].clear(); fru = 0; fva = 0; for(j=0; j<ar[i].size(); j++) { fn = ar[i][j]; while(fru < cli[dep-1].size() && cli[dep-1][fru] < fn) { cli[dep].push_back(cli[dep-1][fru]); fru ++; } cli[dep].push_back(fn); fva += fru; fst[j] = fva + avinv[j+1]; } while(fru < cli[dep-1].size()) { cli[dep].push_back(cli[dep-1][fru]); fru ++; } fru = cli[dep-1].size()-1; fva = 0; cmi = fst[ar[i].size()-1]; for(j=ar[i].size()-1; j>=0; j--) { fn = ar[i][j]; while(fru >= 0 && cli[dep-1][fru] > fn) { fru --; } fva += cli[dep-1].size() - fru - 1; if(j > 0) { cmi = min(cmi,fst[j-1] + fva + avinv[ar[i].size() - j]); } else { cmi = min(cmi, fva + avinv[ar[i].size() - j]); } } if(dp[cn] == -1) { dp[cn] = cmi + dp[cfr]; } else { dp[cn] = min(dp[cn],cmi+dp[cfr]); } // re(i,dep+1,cru,cva + cmi); // u[i] = 0; } } return 0; } int main() { int i,j,m,cn,cm,fn,fm,cru = 0,la; double p; scanf("%s",&s); n = strlen(s); for(i=2; i<=n; i++) { p = i; avinv[i] = p*(p-1) / 4; } for(i=0; i<30; i++) { alp[i] = -1; } for(i=0; i<n; i++) { cn = s[i] - 'A' + 1; if(alp[cn] == -1) { alp[cn] = cru; cru ++; } cm = alp[cn]; ar[cm].push_back(i); } for(i=1; i<min(33000,mxn); i++) { dp[i] = -1; } dp[0] = 0; la = (1<<cru) - 1; re(la,1,cru,0); printf("%.3lf\n",dp[la]); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 47496 KB | found '100800.5000000000', expected '100800.5000000000', error '0.0000000000' |
2 | Correct | 21 ms | 47516 KB | found '0.0000000000', expected '0.0000000000', error '-0.0000000000' |
3 | Correct | 21 ms | 47444 KB | found '0.0000000000', expected '0.0000000000', error '-0.0000000000' |
4 | Correct | 20 ms | 47508 KB | found '1.0000000000', expected '1.0000000000', error '0.0000000000' |
5 | Correct | 20 ms | 47492 KB | found '124002.0000000000', expected '124002.0000000000', error '0.0000000000' |
6 | Correct | 26 ms | 49748 KB | found '772893586.0000000000', expected '772893586.0000000000', error '0.0000000000' |
7 | Correct | 23 ms | 50012 KB | found '1100977812.5000000000', expected '1100977812.5000000000', error '0.0000000000' |
8 | Correct | 27 ms | 50040 KB | found '1249950000.5000000000', expected '1249950000.5000000000', error '0.0000000000' |
9 | Correct | 21 ms | 50128 KB | found '1249975000.0000000000', expected '1249975000.0000000000', error '0.0000000000' |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 47568 KB | found '1.0000000000', expected '1.0000000000', error '0.0000000000' |
2 | Correct | 19 ms | 47524 KB | found '1225.0000000000', expected '1225.0000000000', error '0.0000000000' |
3 | Correct | 22 ms | 47508 KB | found '1023.0000000000', expected '1023.0000000000', error '0.0000000000' |
4 | Correct | 20 ms | 47572 KB | found '294.0000000000', expected '294.0000000000', error '0.0000000000' |
5 | Correct | 19 ms | 47572 KB | found '1087.0000000000', expected '1087.0000000000', error '0.0000000000' |
6 | Correct | 20 ms | 47444 KB | found '1.5000000000', expected '1.5000000000', error '0.0000000000' |
7 | Correct | 20 ms | 47572 KB | found '703.0000000000', expected '703.0000000000', error '0.0000000000' |
8 | Correct | 21 ms | 47572 KB | found '55.5000000000', expected '55.5000000000', error '0.0000000000' |
9 | Correct | 21 ms | 47508 KB | found '56.0000000000', expected '56.0000000000', error '0.0000000000' |
10 | Correct | 26 ms | 47504 KB | found '45.0000000000', expected '45.0000000000', error '0.0000000000' |
11 | Correct | 21 ms | 47452 KB | found '66.5000000000', expected '66.5000000000', error '0.0000000000' |
12 | Correct | 21 ms | 47504 KB | found '67.0000000000', expected '67.0000000000', error '0.0000000000' |
13 | Correct | 20 ms | 47468 KB | found '66.0000000000', expected '66.0000000000', error '0.0000000000' |
14 | Correct | 20 ms | 47448 KB | found '47.0000000000', expected '47.0000000000', error '0.0000000000' |
15 | Correct | 20 ms | 47572 KB | found '50.0000000000', expected '50.0000000000', error '0.0000000000' |
16 | Correct | 20 ms | 47456 KB | found '49.0000000000', expected '49.0000000000', error '0.0000000000' |
17 | Correct | 20 ms | 47492 KB | found '57.0000000000', expected '57.0000000000', error '0.0000000000' |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 19 ms | 47568 KB | found '1.0000000000', expected '1.0000000000', error '0.0000000000' |
2 | Correct | 19 ms | 47524 KB | found '1225.0000000000', expected '1225.0000000000', error '0.0000000000' |
3 | Correct | 22 ms | 47508 KB | found '1023.0000000000', expected '1023.0000000000', error '0.0000000000' |
4 | Correct | 20 ms | 47572 KB | found '294.0000000000', expected '294.0000000000', error '0.0000000000' |
5 | Correct | 19 ms | 47572 KB | found '1087.0000000000', expected '1087.0000000000', error '0.0000000000' |
6 | Correct | 20 ms | 47444 KB | found '1.5000000000', expected '1.5000000000', error '0.0000000000' |
7 | Correct | 20 ms | 47572 KB | found '703.0000000000', expected '703.0000000000', error '0.0000000000' |
8 | Correct | 21 ms | 47572 KB | found '55.5000000000', expected '55.5000000000', error '0.0000000000' |
9 | Correct | 21 ms | 47508 KB | found '56.0000000000', expected '56.0000000000', error '0.0000000000' |
10 | Correct | 26 ms | 47504 KB | found '45.0000000000', expected '45.0000000000', error '0.0000000000' |
11 | Correct | 21 ms | 47452 KB | found '66.5000000000', expected '66.5000000000', error '0.0000000000' |
12 | Correct | 21 ms | 47504 KB | found '67.0000000000', expected '67.0000000000', error '0.0000000000' |
13 | Correct | 20 ms | 47468 KB | found '66.0000000000', expected '66.0000000000', error '0.0000000000' |
14 | Correct | 20 ms | 47448 KB | found '47.0000000000', expected '47.0000000000', error '0.0000000000' |
15 | Correct | 20 ms | 47572 KB | found '50.0000000000', expected '50.0000000000', error '0.0000000000' |
16 | Correct | 20 ms | 47456 KB | found '49.0000000000', expected '49.0000000000', error '0.0000000000' |
17 | Correct | 20 ms | 47492 KB | found '57.0000000000', expected '57.0000000000', error '0.0000000000' |
18 | Correct | 19 ms | 47444 KB | found '1.0000000000', expected '1.0000000000', error '0.0000000000' |
19 | Correct | 25 ms | 47504 KB | found '1225.0000000000', expected '1225.0000000000', error '0.0000000000' |
20 | Correct | 21 ms | 47500 KB | found '1023.0000000000', expected '1023.0000000000', error '0.0000000000' |
21 | Correct | 25 ms | 47484 KB | found '294.0000000000', expected '294.0000000000', error '0.0000000000' |
22 | Correct | 22 ms | 47572 KB | found '1087.0000000000', expected '1087.0000000000', error '0.0000000000' |
23 | Correct | 23 ms | 47528 KB | found '1.5000000000', expected '1.5000000000', error '0.0000000000' |
24 | Correct | 22 ms | 47572 KB | found '703.0000000000', expected '703.0000000000', error '0.0000000000' |
25 | Correct | 21 ms | 47572 KB | found '55.5000000000', expected '55.5000000000', error '0.0000000000' |
26 | Correct | 21 ms | 47544 KB | found '56.0000000000', expected '56.0000000000', error '0.0000000000' |
27 | Correct | 26 ms | 47532 KB | found '45.0000000000', expected '45.0000000000', error '0.0000000000' |
28 | Correct | 21 ms | 47528 KB | found '66.5000000000', expected '66.5000000000', error '0.0000000000' |
29 | Correct | 22 ms | 47600 KB | found '67.0000000000', expected '67.0000000000', error '0.0000000000' |
30 | Correct | 21 ms | 47560 KB | found '66.0000000000', expected '66.0000000000', error '0.0000000000' |
31 | Correct | 21 ms | 47504 KB | found '47.0000000000', expected '47.0000000000', error '0.0000000000' |
32 | Correct | 20 ms | 47444 KB | found '50.0000000000', expected '50.0000000000', error '0.0000000000' |
33 | Correct | 21 ms | 47564 KB | found '49.0000000000', expected '49.0000000000', error '0.0000000000' |
34 | Correct | 21 ms | 47516 KB | found '57.0000000000', expected '57.0000000000', error '0.0000000000' |
35 | Correct | 23 ms | 47844 KB | found '12497500.0000000000', expected '12497500.0000000000', error '0.0000000000' |
36 | Correct | 23 ms | 47856 KB | found '12495000.5000000000', expected '12495000.5000000000', error '0.0000000000' |
37 | Correct | 455 ms | 47872 KB | found '12223392.0000000000', expected '12223392.0000000000', error '0.0000000000' |
38 | Correct | 156 ms | 47832 KB | found '2372500.0000000000', expected '2372500.0000000000', error '0.0000000000' |
39 | Correct | 191 ms | 47952 KB | found '12475017.5000000000', expected '12475017.5000000000', error '0.0000000000' |
40 | Correct | 143 ms | 47776 KB | found '10655706.0000000000', expected '10655706.0000000000', error '0.0000000000' |
41 | Correct | 145 ms | 47828 KB | found '11977895.5000000000', expected '11977895.5000000000', error '0.0000000000' |
42 | Correct | 160 ms | 47844 KB | found '11977865.0000000000', expected '11977865.0000000000', error '0.0000000000' |
43 | Correct | 147 ms | 47888 KB | found '11977907.5000000000', expected '11977907.5000000000', error '0.0000000000' |
44 | Correct | 145 ms | 47884 KB | found '11977808.0000000000', expected '11977808.0000000000', error '0.0000000000' |
45 | Correct | 189 ms | 47888 KB | found '11977791.0000000000', expected '11977791.0000000000', error '0.0000000000' |
46 | Correct | 149 ms | 47888 KB | found '11977871.5000000000', expected '11977871.5000000000', error '0.0000000000' |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 24 ms | 47496 KB | found '100800.5000000000', expected '100800.5000000000', error '0.0000000000' |
2 | Correct | 21 ms | 47516 KB | found '0.0000000000', expected '0.0000000000', error '-0.0000000000' |
3 | Correct | 21 ms | 47444 KB | found '0.0000000000', expected '0.0000000000', error '-0.0000000000' |
4 | Correct | 20 ms | 47508 KB | found '1.0000000000', expected '1.0000000000', error '0.0000000000' |
5 | Correct | 20 ms | 47492 KB | found '124002.0000000000', expected '124002.0000000000', error '0.0000000000' |
6 | Correct | 26 ms | 49748 KB | found '772893586.0000000000', expected '772893586.0000000000', error '0.0000000000' |
7 | Correct | 23 ms | 50012 KB | found '1100977812.5000000000', expected '1100977812.5000000000', error '0.0000000000' |
8 | Correct | 27 ms | 50040 KB | found '1249950000.5000000000', expected '1249950000.5000000000', error '0.0000000000' |
9 | Correct | 21 ms | 50128 KB | found '1249975000.0000000000', expected '1249975000.0000000000', error '0.0000000000' |
10 | Correct | 19 ms | 47568 KB | found '1.0000000000', expected '1.0000000000', error '0.0000000000' |
11 | Correct | 19 ms | 47524 KB | found '1225.0000000000', expected '1225.0000000000', error '0.0000000000' |
12 | Correct | 22 ms | 47508 KB | found '1023.0000000000', expected '1023.0000000000', error '0.0000000000' |
13 | Correct | 20 ms | 47572 KB | found '294.0000000000', expected '294.0000000000', error '0.0000000000' |
14 | Correct | 19 ms | 47572 KB | found '1087.0000000000', expected '1087.0000000000', error '0.0000000000' |
15 | Correct | 20 ms | 47444 KB | found '1.5000000000', expected '1.5000000000', error '0.0000000000' |
16 | Correct | 20 ms | 47572 KB | found '703.0000000000', expected '703.0000000000', error '0.0000000000' |
17 | Correct | 21 ms | 47572 KB | found '55.5000000000', expected '55.5000000000', error '0.0000000000' |
18 | Correct | 21 ms | 47508 KB | found '56.0000000000', expected '56.0000000000', error '0.0000000000' |
19 | Correct | 26 ms | 47504 KB | found '45.0000000000', expected '45.0000000000', error '0.0000000000' |
20 | Correct | 21 ms | 47452 KB | found '66.5000000000', expected '66.5000000000', error '0.0000000000' |
21 | Correct | 21 ms | 47504 KB | found '67.0000000000', expected '67.0000000000', error '0.0000000000' |
22 | Correct | 20 ms | 47468 KB | found '66.0000000000', expected '66.0000000000', error '0.0000000000' |
23 | Correct | 20 ms | 47448 KB | found '47.0000000000', expected '47.0000000000', error '0.0000000000' |
24 | Correct | 20 ms | 47572 KB | found '50.0000000000', expected '50.0000000000', error '0.0000000000' |
25 | Correct | 20 ms | 47456 KB | found '49.0000000000', expected '49.0000000000', error '0.0000000000' |
26 | Correct | 20 ms | 47492 KB | found '57.0000000000', expected '57.0000000000', error '0.0000000000' |
27 | Correct | 19 ms | 47444 KB | found '1.0000000000', expected '1.0000000000', error '0.0000000000' |
28 | Correct | 25 ms | 47504 KB | found '1225.0000000000', expected '1225.0000000000', error '0.0000000000' |
29 | Correct | 21 ms | 47500 KB | found '1023.0000000000', expected '1023.0000000000', error '0.0000000000' |
30 | Correct | 25 ms | 47484 KB | found '294.0000000000', expected '294.0000000000', error '0.0000000000' |
31 | Correct | 22 ms | 47572 KB | found '1087.0000000000', expected '1087.0000000000', error '0.0000000000' |
32 | Correct | 23 ms | 47528 KB | found '1.5000000000', expected '1.5000000000', error '0.0000000000' |
33 | Correct | 22 ms | 47572 KB | found '703.0000000000', expected '703.0000000000', error '0.0000000000' |
34 | Correct | 21 ms | 47572 KB | found '55.5000000000', expected '55.5000000000', error '0.0000000000' |
35 | Correct | 21 ms | 47544 KB | found '56.0000000000', expected '56.0000000000', error '0.0000000000' |
36 | Correct | 26 ms | 47532 KB | found '45.0000000000', expected '45.0000000000', error '0.0000000000' |
37 | Correct | 21 ms | 47528 KB | found '66.5000000000', expected '66.5000000000', error '0.0000000000' |
38 | Correct | 22 ms | 47600 KB | found '67.0000000000', expected '67.0000000000', error '0.0000000000' |
39 | Correct | 21 ms | 47560 KB | found '66.0000000000', expected '66.0000000000', error '0.0000000000' |
40 | Correct | 21 ms | 47504 KB | found '47.0000000000', expected '47.0000000000', error '0.0000000000' |
41 | Correct | 20 ms | 47444 KB | found '50.0000000000', expected '50.0000000000', error '0.0000000000' |
42 | Correct | 21 ms | 47564 KB | found '49.0000000000', expected '49.0000000000', error '0.0000000000' |
43 | Correct | 21 ms | 47516 KB | found '57.0000000000', expected '57.0000000000', error '0.0000000000' |
44 | Correct | 23 ms | 47844 KB | found '12497500.0000000000', expected '12497500.0000000000', error '0.0000000000' |
45 | Correct | 23 ms | 47856 KB | found '12495000.5000000000', expected '12495000.5000000000', error '0.0000000000' |
46 | Correct | 455 ms | 47872 KB | found '12223392.0000000000', expected '12223392.0000000000', error '0.0000000000' |
47 | Correct | 156 ms | 47832 KB | found '2372500.0000000000', expected '2372500.0000000000', error '0.0000000000' |
48 | Correct | 191 ms | 47952 KB | found '12475017.5000000000', expected '12475017.5000000000', error '0.0000000000' |
49 | Correct | 143 ms | 47776 KB | found '10655706.0000000000', expected '10655706.0000000000', error '0.0000000000' |
50 | Correct | 145 ms | 47828 KB | found '11977895.5000000000', expected '11977895.5000000000', error '0.0000000000' |
51 | Correct | 160 ms | 47844 KB | found '11977865.0000000000', expected '11977865.0000000000', error '0.0000000000' |
52 | Correct | 147 ms | 47888 KB | found '11977907.5000000000', expected '11977907.5000000000', error '0.0000000000' |
53 | Correct | 145 ms | 47884 KB | found '11977808.0000000000', expected '11977808.0000000000', error '0.0000000000' |
54 | Correct | 189 ms | 47888 KB | found '11977791.0000000000', expected '11977791.0000000000', error '0.0000000000' |
55 | Correct | 149 ms | 47888 KB | found '11977871.5000000000', expected '11977871.5000000000', error '0.0000000000' |
56 | Correct | 21 ms | 47444 KB | found '7.5000000000', expected '7.5000000000', error '0.0000000000' |
57 | Correct | 67 ms | 47548 KB | found '0.0000000000', expected '0.0000000000', error '-0.0000000000' |
58 | Correct | 20 ms | 47512 KB | found '100800.5000000000', expected '100800.5000000000', error '0.0000000000' |
59 | Correct | 25 ms | 47564 KB | found '0.0000000000', expected '0.0000000000', error '-0.0000000000' |
60 | Correct | 20 ms | 47548 KB | found '0.0000000000', expected '0.0000000000', error '-0.0000000000' |
61 | Correct | 21 ms | 47444 KB | found '1.0000000000', expected '1.0000000000', error '0.0000000000' |
62 | Correct | 20 ms | 47520 KB | found '124002.0000000000', expected '124002.0000000000', error '0.0000000000' |
63 | Correct | 22 ms | 49740 KB | found '772893586.0000000000', expected '772893586.0000000000', error '0.0000000000' |
64 | Correct | 23 ms | 49996 KB | found '1100977812.5000000000', expected '1100977812.5000000000', error '0.0000000000' |
65 | Correct | 22 ms | 50088 KB | found '1249950000.5000000000', expected '1249950000.5000000000', error '0.0000000000' |
66 | Correct | 23 ms | 50128 KB | found '1249975000.0000000000', expected '1249975000.0000000000', error '0.0000000000' |
67 | Correct | 20 ms | 47564 KB | found '1.0000000000', expected '1.0000000000', error '0.0000000000' |
68 | Correct | 20 ms | 47580 KB | found '1225.0000000000', expected '1225.0000000000', error '0.0000000000' |
69 | Correct | 21 ms | 47468 KB | found '1023.0000000000', expected '1023.0000000000', error '0.0000000000' |
70 | Correct | 21 ms | 47572 KB | found '294.0000000000', expected '294.0000000000', error '0.0000000000' |
71 | Correct | 20 ms | 47572 KB | found '1087.0000000000', expected '1087.0000000000', error '0.0000000000' |
72 | Correct | 23 ms | 47516 KB | found '1.5000000000', expected '1.5000000000', error '0.0000000000' |
73 | Correct | 21 ms | 47504 KB | found '703.0000000000', expected '703.0000000000', error '0.0000000000' |
74 | Correct | 22 ms | 47452 KB | found '55.5000000000', expected '55.5000000000', error '0.0000000000' |
75 | Correct | 20 ms | 47572 KB | found '56.0000000000', expected '56.0000000000', error '0.0000000000' |
76 | Correct | 21 ms | 47572 KB | found '45.0000000000', expected '45.0000000000', error '0.0000000000' |
77 | Correct | 22 ms | 47540 KB | found '66.5000000000', expected '66.5000000000', error '0.0000000000' |
78 | Correct | 21 ms | 47468 KB | found '67.0000000000', expected '67.0000000000', error '0.0000000000' |
79 | Correct | 21 ms | 47512 KB | found '66.0000000000', expected '66.0000000000', error '0.0000000000' |
80 | Correct | 21 ms | 47524 KB | found '47.0000000000', expected '47.0000000000', error '0.0000000000' |
81 | Correct | 21 ms | 47484 KB | found '50.0000000000', expected '50.0000000000', error '0.0000000000' |
82 | Correct | 20 ms | 47528 KB | found '49.0000000000', expected '49.0000000000', error '0.0000000000' |
83 | Correct | 21 ms | 47560 KB | found '57.0000000000', expected '57.0000000000', error '0.0000000000' |
84 | Correct | 21 ms | 47816 KB | found '12497500.0000000000', expected '12497500.0000000000', error '0.0000000000' |
85 | Correct | 21 ms | 47804 KB | found '12495000.5000000000', expected '12495000.5000000000', error '0.0000000000' |
86 | Correct | 439 ms | 47784 KB | found '12223392.0000000000', expected '12223392.0000000000', error '0.0000000000' |
87 | Correct | 160 ms | 47836 KB | found '2372500.0000000000', expected '2372500.0000000000', error '0.0000000000' |
88 | Correct | 173 ms | 47944 KB | found '12475017.5000000000', expected '12475017.5000000000', error '0.0000000000' |
89 | Correct | 154 ms | 47844 KB | found '10655706.0000000000', expected '10655706.0000000000', error '0.0000000000' |
90 | Correct | 201 ms | 47888 KB | found '11977895.5000000000', expected '11977895.5000000000', error '0.0000000000' |
91 | Correct | 155 ms | 47948 KB | found '11977865.0000000000', expected '11977865.0000000000', error '0.0000000000' |
92 | Correct | 180 ms | 47820 KB | found '11977907.5000000000', expected '11977907.5000000000', error '0.0000000000' |
93 | Correct | 200 ms | 47876 KB | found '11977808.0000000000', expected '11977808.0000000000', error '0.0000000000' |
94 | Correct | 191 ms | 47780 KB | found '11977791.0000000000', expected '11977791.0000000000', error '0.0000000000' |
95 | Correct | 166 ms | 47804 KB | found '11977871.5000000000', expected '11977871.5000000000', error '0.0000000000' |
96 | Execution timed out | 2087 ms | 49896 KB | Time limit exceeded |
97 | Halted | 0 ms | 0 KB | - |