Submission #8533793
Source Code Expand
#include<bits/stdc++.h> using namespace std; char p1[42000010]; int n,k,bg[21][1<<20|3],cnt,p2[42000010],d[42000010],h1[1<<20|3],h0[1<<20|3],q[42000010],l,r,an,ans,f[42000010]; char s[21][1<<20|3]; int main() { h1[0]=-1,h1[1]=0; for (int i=2; i<(1<<20); i++) h1[i]=h1[i>>1]+1; h0[0]=h0[1]=-1; for (int i=2; i<(1<<20); i++) { h0[i]=-1; for (int j=h1[i]; j>=0; j--) if (!(i>>j&1)) {h0[i]=j; break;} } scanf("%d%d",&n,&k),cnt=0; for (int i=0; i<=n; i++) scanf("%s",s[i]); for (int i=0; i<=n; i++) for (int j=0; j<(1<<i); j++) { bg[i][j]=(++cnt); for (int k=cnt; k<=cnt+i; k++) p1[k]=i,p2[k]=j; cnt+=i; } for (int i=cnt; i; i--) if (i!=bg[p1[i]][p2[i]]) { int len=p1[i]-(i-bg[p1[i]][p2[i]]); d[bg[len][p2[i]&((1<<len)-1)]]++; if (h1[p2[i]]>=len) d[bg[h1[p2[i]]+1][(((p2[i]-(1<<h1[p2[i]]))>>len)<<len+1)|((p2[i]&((1<<len)-1))<<1)|1]+h1[p2[i]]-len]++; int p=-1; if (h1[p2[i]]!=p1[i]-1) p=p1[i]-1; else p=h0[p2[i]]; if (p>=len) d[bg[p+1][(((p2[i]&((1<<p)-1))>>len)<<len+1)|((p2[i]&(1<<len)-1)<<1)]+p-len]++; } l=1,r=0,an=-1; for (int i=1; i<=cnt; i++) if (!d[i]) q[++r]=i; while (l<=r) { int i=q[l++],len=p1[i]-(i-bg[p1[i]][p2[i]]),t; if (i==bg[p1[i]][p2[i]]) { if (f[i]<k) continue; if (p1[i]>an) an=p1[i],ans=p2[i]; else if (p1[i]==an&&ans>p2[i]) ans=p2[i]; } else { if (i==bg[p1[i]][p2[i]]+p1[i]&&s[p1[i]][p2[i]]=='1') f[i]++; t=bg[len][p2[i]&((1<<len)-1)],f[t]+=f[i]; if (!--d[t]) q[++r]=t; if (h1[p2[i]]>=len) { t=bg[h1[p2[i]]+1][(((p2[i]-(1<<h1[p2[i]]))>>len)<<len+1)|((p2[i]&((1<<len)-1))<<1)|1]+h1[p2[i]]-len; f[t]+=f[i]; if (!--d[t]) q[++r]=t; } int p=-1; if (h1[p2[i]]!=p1[i]-1) p=p1[i]-1; else p=h0[p2[i]]; if (p>=len) { t=bg[p+1][(((p2[i]&((1<<p)-1))>>len)<<len+1)|((p2[i]&(1<<len)-1)<<1)]+p-len; f[t]+=f[i]; if (!--d[t]) q[++r]=t; } } } for (int i=an-1; i>=0; i--) putchar((ans>>i&1)+'0'); return puts(""),0; }
Submission Info
Submission Time | |
---|---|
Task | F - Simple Subsequence Problem |
User | panole |
Language | C++14 (GCC 5.4.1) |
Score | 0 |
Code Size | 2022 Byte |
Status | TLE |
Exec Time | 2105 ms |
Memory | 659584 KB |
Compile Error
./Main.cpp: In function ‘int main()’: ./Main.cpp:19:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] scanf("%d%d",&n,&k),cnt=0; ^ ./Main.cpp:20:43: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result] for (int i=0; i<=n; i++) scanf("%s",s[i]); ^
Judge Result
Set Name | Sample | All | ||||||
---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 2300 | ||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 27.txt, 28.txt, 29.txt, 30.txt, 31.txt, 32.txt, 33.txt, 34.txt, 35.txt, 36.txt, 37.txt, 38.txt, 39.txt, 40.txt, 41.txt, 42.txt, 43.txt, 44.txt, 45.txt, 46.txt, 47.txt, 48.txt, 49.txt, 50.txt, 51.txt, 52.txt, 53.txt, 54.txt, 55.txt, 56.txt, 57.txt, 58.txt, 59.txt, 60.txt, 61.txt, 62.txt, 63.txt, 64.txt, 65.txt, 66.txt, 67.txt, 68.txt, 69.txt, 70.txt, 71.txt, 72.txt, 73.txt, 74.txt, 75.txt, 76.txt, 77.txt, 78.txt, 79.txt, 80.txt, 81.txt, 82.txt, 83.txt, 84.txt, 85.txt, 86.txt, 87.txt, 88.txt, 89.txt, 90.txt, 91.txt, 92.txt, 93.txt, 94.txt, 95.txt, 96.txt, 97.txt, 98.txt, 99.txt, A0.txt, A1.txt, A2.txt, A3.txt, A4.txt, A5.txt, A6.txt, A7.txt, A8.txt, A9.txt, B0.txt, B1.txt, B2.txt, B3.txt, B4.txt, B5.txt, B6.txt, B7.txt, B8.txt, B9.txt, C0.txt, C1.txt, C2.txt, C3.txt, C4.txt, C5.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | TLE | 2105 ms | 659584 KB |
02.txt | TLE | 2105 ms | 659584 KB |
03.txt | TLE | 2105 ms | 659584 KB |
04.txt | TLE | 2105 ms | 659584 KB |
05.txt | TLE | 2105 ms | 659584 KB |
06.txt | TLE | 2105 ms | 659584 KB |
07.txt | TLE | 2105 ms | 659584 KB |
08.txt | TLE | 2105 ms | 659584 KB |
09.txt | TLE | 2105 ms | 659584 KB |
10.txt | TLE | 2105 ms | 659584 KB |
11.txt | TLE | 2105 ms | 659584 KB |
12.txt | TLE | 2105 ms | 659584 KB |
13.txt | TLE | 2105 ms | 659584 KB |
14.txt | TLE | 2105 ms | 659584 KB |
15.txt | TLE | 2105 ms | 659584 KB |
16.txt | TLE | 2105 ms | 659584 KB |
17.txt | TLE | 2105 ms | 659584 KB |
18.txt | TLE | 2105 ms | 659584 KB |
19.txt | TLE | 2105 ms | 659584 KB |
20.txt | TLE | 2105 ms | 659584 KB |
21.txt | TLE | 2105 ms | 659584 KB |
22.txt | TLE | 2105 ms | 659584 KB |
23.txt | TLE | 2105 ms | 659584 KB |
24.txt | TLE | 2105 ms | 659584 KB |
25.txt | TLE | 2105 ms | 659584 KB |
26.txt | TLE | 2105 ms | 659584 KB |
27.txt | TLE | 2105 ms | 659584 KB |
28.txt | TLE | 2105 ms | 659584 KB |
29.txt | TLE | 2105 ms | 659584 KB |
30.txt | TLE | 2105 ms | 659584 KB |
31.txt | TLE | 2105 ms | 659584 KB |
32.txt | TLE | 2105 ms | 659584 KB |
33.txt | TLE | 2105 ms | 659584 KB |
34.txt | TLE | 2105 ms | 659584 KB |
35.txt | TLE | 2105 ms | 659584 KB |
36.txt | TLE | 2105 ms | 659584 KB |
37.txt | TLE | 2105 ms | 659584 KB |
38.txt | TLE | 2105 ms | 659584 KB |
39.txt | TLE | 2105 ms | 659584 KB |
40.txt | TLE | 2105 ms | 659584 KB |
41.txt | TLE | 2105 ms | 659584 KB |
42.txt | TLE | 2105 ms | 659584 KB |
43.txt | TLE | 2105 ms | 659584 KB |
44.txt | TLE | 2105 ms | 659584 KB |
45.txt | TLE | 2105 ms | 659584 KB |
46.txt | TLE | 2105 ms | 659584 KB |
47.txt | TLE | 2105 ms | 659584 KB |
48.txt | TLE | 2105 ms | 659584 KB |
49.txt | TLE | 2105 ms | 659584 KB |
50.txt | TLE | 2105 ms | 659584 KB |
51.txt | TLE | 2105 ms | 659584 KB |
52.txt | TLE | 2105 ms | 657536 KB |
53.txt | TLE | 2105 ms | 659584 KB |
54.txt | TLE | 2105 ms | 659584 KB |
55.txt | AC | 11 ms | 35072 KB |
56.txt | AC | 9 ms | 22784 KB |
57.txt | TLE | 2105 ms | 659584 KB |
58.txt | AC | 13 ms | 41216 KB |
59.txt | AC | 10 ms | 28928 KB |
60.txt | AC | 674 ms | 157952 KB |
61.txt | AC | 11 ms | 33024 KB |
62.txt | AC | 11 ms | 33024 KB |
63.txt | AC | 673 ms | 157952 KB |
64.txt | AC | 12 ms | 39168 KB |
65.txt | AC | 10 ms | 28928 KB |
66.txt | AC | 13 ms | 45312 KB |
67.txt | AC | 13 ms | 41216 KB |
68.txt | TLE | 2105 ms | 659584 KB |
69.txt | TLE | 2105 ms | 659584 KB |
70.txt | TLE | 2105 ms | 659584 KB |
71.txt | TLE | 2105 ms | 659584 KB |
72.txt | TLE | 2105 ms | 659584 KB |
73.txt | TLE | 2105 ms | 659584 KB |
74.txt | AC | 13 ms | 45312 KB |
75.txt | AC | 28 ms | 67840 KB |
76.txt | TLE | 2105 ms | 659584 KB |
77.txt | TLE | 2105 ms | 659584 KB |
78.txt | TLE | 2105 ms | 659584 KB |
79.txt | TLE | 2105 ms | 659584 KB |
80.txt | TLE | 2105 ms | 659584 KB |
81.txt | TLE | 2105 ms | 659584 KB |
82.txt | TLE | 2105 ms | 659584 KB |
83.txt | TLE | 2105 ms | 659584 KB |
84.txt | TLE | 2105 ms | 659584 KB |
85.txt | TLE | 2105 ms | 659584 KB |
86.txt | TLE | 2105 ms | 659584 KB |
87.txt | TLE | 2105 ms | 659584 KB |
88.txt | TLE | 2105 ms | 659584 KB |
89.txt | TLE | 2105 ms | 659584 KB |
90.txt | TLE | 2105 ms | 659584 KB |
91.txt | TLE | 2105 ms | 659584 KB |
92.txt | TLE | 2105 ms | 659584 KB |
93.txt | TLE | 2105 ms | 659584 KB |
94.txt | TLE | 2105 ms | 659584 KB |
95.txt | TLE | 2105 ms | 659584 KB |
96.txt | TLE | 2105 ms | 659584 KB |
97.txt | TLE | 2105 ms | 659584 KB |
98.txt | TLE | 2105 ms | 659584 KB |
99.txt | TLE | 2105 ms | 659584 KB |
A0.txt | TLE | 2105 ms | 659584 KB |
A1.txt | TLE | 2105 ms | 659584 KB |
A2.txt | TLE | 2105 ms | 659584 KB |
A3.txt | TLE | 2105 ms | 659584 KB |
A4.txt | TLE | 2105 ms | 659584 KB |
A5.txt | TLE | 2105 ms | 659584 KB |
A6.txt | TLE | 2105 ms | 659584 KB |
A7.txt | TLE | 2105 ms | 659584 KB |
A8.txt | TLE | 2105 ms | 659584 KB |
A9.txt | TLE | 2105 ms | 659584 KB |
B0.txt | TLE | 2105 ms | 659584 KB |
B1.txt | TLE | 2105 ms | 659584 KB |
B2.txt | TLE | 2105 ms | 659584 KB |
B3.txt | TLE | 2105 ms | 659584 KB |
B4.txt | TLE | 2105 ms | 659584 KB |
B5.txt | TLE | 2105 ms | 659584 KB |
B6.txt | TLE | 2105 ms | 659584 KB |
B7.txt | TLE | 2105 ms | 659584 KB |
B8.txt | TLE | 2105 ms | 659584 KB |
B9.txt | TLE | 2105 ms | 659584 KB |
C0.txt | TLE | 2105 ms | 659584 KB |
C1.txt | AC | 9 ms | 22784 KB |
C2.txt | AC | 8 ms | 18688 KB |
C3.txt | AC | 9 ms | 22784 KB |
C4.txt | AC | 9 ms | 22784 KB |
C5.txt | AC | 9 ms | 22784 KB |
s1.txt | AC | 10 ms | 28928 KB |
s2.txt | AC | 11 ms | 33024 KB |
s3.txt | AC | 10 ms | 26880 KB |