Submission #2540895


Source Code Expand

Copy
#include<stdio.h>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<bitset>
#include<utility>
#include<functional>
#include<iomanip>
#include<sstream>
#include<ctime>
#include<cassert>
using namespace std;
#define y0 y0z
#define y1 y1z
#define yn ynz
#define j0 j0z
#define j1 j1z
#define jn jnz
#define tm tmz
#define buli(x) (__builtin_popcountll(x))
#define bur0(x) (__builtin_ctzll(x))
#define bul2(x) (63-__builtin_clzll(x))
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define fil(a,b) memset((a),(b),sizeof(a))
#define cl(a) fil(a,0)
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define foreach(it,a) for(__typeof((a).begin()) it=(a).begin();it!=(a).end();it++)
#define rep(i,a,b) for (int i=(a),_ed=(b);i<_ed;i++)
#define per(i,a,b) for (int i=(b)-1,_ed=(a);i>=_ed;i--)
#define forg(i,gu) for (int i=gu;~i;i=e[i].next)
#define pw(x) ((ll(1))<<(x))
#define upmo(a,b) (((a)=((a)+(b))%mo)<0?(a)+=mo:(a))
#define mmo(a,b) (((a)=1ll*(a)*(b)%mo)<0?(a)+=mo:(a))
void getre(){int x=0;printf("%d\n",1/x);}
void gettle(){int res=1;while(1)res<<=1;printf("%d\n",res);}
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
template<typename T,typename S>inline bool upmin(T&a,const S&b){return a>b?a=b,1:0;}
template<typename T,typename S>inline bool upmax(T&a,const S&b){return a<b?a=b,1:0;}
template<typename N,typename PN>inline N flo(N a,PN b){return a>=0?a/b:-((-a-1)/b)-1;}
template<typename N,typename PN>inline N cei(N a,PN b){return a>0?(a-1)/b+1:-(-a/b);}
template<typename N>N gcd(N a,N b){return b?gcd(b,a%b):a;}
template<typename N>inline int sgn(N a){return a>0?1:(a<0?-1:0);}
#if ( ( _WIN32 || __WIN32__ ) && __cplusplus < 201103L)
#define lld "%I64d"
#else
#define lld "%lld"
#endif
inline void gn(long long&x){
	int sg=1;char c;while(((c=getchar())<'0'||c>'9')&&c!='-');
	c=='-'?(sg=-1,x=0):(x=c-'0');
	while((c=getchar())>='0'&&c<='9')x=x*10+c-'0';x*=sg;
}
inline void gn(int&x){long long t;gn(t);x=t;}
inline void gn(unsigned long long&x){long long t;gn(t);x=t;}
inline void gn(double&x){double t;scanf("%lf",&t);x=t;}
inline void gn(long double&x){double t;scanf("%lf",&t);x=t;}
inline void gs(char *s){scanf("%s",s);}
inline void gc(char &c){while((c=getchar())>126 || c<33);}
inline void pc(char c){putchar(c);}
#ifdef JCVB
#define debug(...) fprintf(stderr, __VA_ARGS__)
#else
#define debug(...)
#endif
typedef long long ll;
typedef double db;
inline ll sqr(ll a){return a*a;}
inline db sqrf(db a){return a*a;}
const int inf=0x3f3f3f3f;
//const ll inf=0x3f3f3f3f3f3f3f3fll;
const db pi=3.14159265358979323846264338327950288L;
const db eps=1e-6;
//const int mo=0;
//int qp(int a,ll b){int n=1;do{if(b&1)n=1ll*n*a%mo;a=1ll*a*a%mo;}while(b>>=1);return n;}


int n;
bool on[21][1<<20];
char s[(1<<20)+5];
int f[21][1<<21];
int ans[21][1<<20];
int K;
int main()
{
	gn(n);
	gn(K);
	rep(i,0,n+1) {
		gs(s);
		rep(j,0,pw(i))on[i][j]=(s[j]=='1');
		rep(j,0,pw(i))if(on[i][j]) {
			f[i][j|pw(i)]=1;
		}
	}
	rep(d,0,n) {// chosen
		rep(lef,1,n-d+1) {
			rep(b,0,pw(d+lef)) {
				int chosen = (b|pw(d+lef))>>lef; //including 1
				rep(nex,0,2) {
					int fon=-1;
					for (int j = lef-1;j>=0;j--)if(((b>>j)&1)==nex){
						fon=j;
						break;
					}
					if(fon==-1)continue;
					int ne = ((chosen<<1|nex)<<(fon)) | (b&(pw(fon)-1));
					f[fon][ne]+=f[lef][b|pw(d+lef)];
				}
			}
		}
	}
	rep(d,0,n+1) {//chosen
		rep(lef,0,n-d+1) {
			rep(b,0,pw(d+lef)) {
				int chosen = (b)>>lef; //including 1
				int nu = f[lef][b|pw(d+lef)];
				ans[d][chosen]+=nu;
			}
		}
	}
	int ma=0;
	rep(d,0,n+1) {
		rep(b,0,pw(d))if(ans[d][b]>=K)upmax(ma,d);
	}
	int mi = inf;
	rep(b,0,pw(ma)) {
		if(ans[ma][b]>=K) upmin(mi,b);
	}
	for(int j=ma-1;j>=0;j--)putchar(((mi>>j)&1)+'0');
	printf("\n");
	return 0;

}

Submission Info

Submission Time
Task F - Simple Subsequence Problem
User jcvb
Language C++14 (GCC 5.4.1)
Score 2300
Code Size 4040 Byte
Status
Exec Time 502 ms
Memory 237952 KB

Compile Error

./Main.cpp: In function ‘void gs(char*)’:
./Main.cpp:69:38: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
 inline void gs(char *s){scanf("%s",s);}
                                      ^

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 s1.txt, s2.txt, s3.txt
All 2300 / 2300 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 495 ms 237824 KB
02.txt 502 ms 237824 KB
03.txt 495 ms 237824 KB
04.txt 490 ms 237824 KB
05.txt 488 ms 237824 KB
06.txt 489 ms 237952 KB
07.txt 488 ms 237824 KB
08.txt 488 ms 237824 KB
09.txt 490 ms 237824 KB
10.txt 486 ms 237824 KB
11.txt 487 ms 237824 KB
12.txt 487 ms 237824 KB
13.txt 488 ms 237824 KB
14.txt 487 ms 237824 KB
15.txt 486 ms 237824 KB
16.txt 486 ms 237824 KB
17.txt 487 ms 237824 KB
18.txt 487 ms 237824 KB
19.txt 492 ms 237824 KB
20.txt 491 ms 237824 KB
21.txt 492 ms 237824 KB
22.txt 492 ms 237824 KB
23.txt 494 ms 237824 KB
24.txt 492 ms 237824 KB
25.txt 487 ms 237824 KB
26.txt 487 ms 237824 KB
27.txt 487 ms 237824 KB
28.txt 487 ms 233728 KB
29.txt 486 ms 237824 KB
30.txt 487 ms 237824 KB
31.txt 494 ms 237824 KB
32.txt 494 ms 237824 KB
33.txt 496 ms 237824 KB
34.txt 489 ms 237824 KB
35.txt 489 ms 237824 KB
36.txt 488 ms 237824 KB
37.txt 487 ms 237824 KB
38.txt 489 ms 237824 KB
39.txt 489 ms 237824 KB
40.txt 488 ms 237824 KB
41.txt 486 ms 237824 KB
42.txt 486 ms 237824 KB
43.txt 490 ms 237824 KB
44.txt 487 ms 237824 KB
45.txt 490 ms 237824 KB
46.txt 488 ms 237824 KB
47.txt 486 ms 237824 KB
48.txt 489 ms 237824 KB
49.txt 486 ms 237824 KB
50.txt 486 ms 237824 KB
51.txt 492 ms 237824 KB
52.txt 492 ms 237824 KB
53.txt 490 ms 237824 KB
54.txt 487 ms 233728 KB
55.txt 7 ms 30976 KB
56.txt 3 ms 10496 KB
57.txt 496 ms 237824 KB
58.txt 9 ms 41216 KB
59.txt 5 ms 20736 KB
60.txt 66 ms 92416 KB
61.txt 6 ms 24832 KB
62.txt 6 ms 24832 KB
63.txt 66 ms 92416 KB
64.txt 8 ms 35072 KB
65.txt 5 ms 20736 KB
66.txt 10 ms 45312 KB
67.txt 9 ms 41216 KB
68.txt 486 ms 233728 KB
69.txt 486 ms 233728 KB
70.txt 486 ms 233728 KB
71.txt 486 ms 233728 KB
72.txt 487 ms 233728 KB
73.txt 486 ms 235776 KB
74.txt 10 ms 45312 KB
75.txt 17 ms 71936 KB
76.txt 494 ms 237824 KB
77.txt 490 ms 237824 KB
78.txt 489 ms 237824 KB
79.txt 489 ms 237824 KB
80.txt 492 ms 237824 KB
81.txt 490 ms 237824 KB
82.txt 493 ms 237824 KB
83.txt 494 ms 237824 KB
84.txt 490 ms 237824 KB
85.txt 487 ms 237824 KB
86.txt 492 ms 237824 KB
87.txt 492 ms 237824 KB
88.txt 499 ms 237824 KB
89.txt 488 ms 237824 KB
90.txt 491 ms 237824 KB
91.txt 492 ms 237824 KB
92.txt 491 ms 237824 KB
93.txt 489 ms 237824 KB
94.txt 494 ms 237824 KB
95.txt 488 ms 237824 KB
96.txt 490 ms 237824 KB
97.txt 495 ms 237824 KB
98.txt 493 ms 237824 KB
99.txt 496 ms 237952 KB
A0.txt 492 ms 237824 KB
A1.txt 491 ms 237952 KB
A2.txt 495 ms 237824 KB
A3.txt 494 ms 237824 KB
A4.txt 494 ms 237824 KB
A5.txt 492 ms 237824 KB
A6.txt 495 ms 237824 KB
A7.txt 491 ms 237824 KB
A8.txt 495 ms 237824 KB
A9.txt 490 ms 237824 KB
B0.txt 491 ms 237824 KB
B1.txt 494 ms 237824 KB
B2.txt 494 ms 237824 KB
B3.txt 492 ms 237824 KB
B4.txt 495 ms 237824 KB
B5.txt 496 ms 237824 KB
B6.txt 494 ms 237824 KB
B7.txt 491 ms 237824 KB
B8.txt 495 ms 237824 KB
B9.txt 493 ms 237824 KB
C0.txt 487 ms 237824 KB
C1.txt 3 ms 10496 KB
C2.txt 2 ms 4352 KB
C3.txt 3 ms 10496 KB
C4.txt 3 ms 10496 KB
C5.txt 3 ms 10496 KB
s1.txt 5 ms 20736 KB
s2.txt 6 ms 24832 KB
s3.txt 4 ms 14592 KB