QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#197500#6380. LaLa and Divination MagicKingSagerAC ✓2551ms9472kbC++148.0kb2023-10-02 16:32:162023-10-02 16:32:16

Judging History

你现在查看的是最新测评结果

  • [2023-10-02 16:32:16]
  • 评测
  • 测评结果:AC
  • 用时:2551ms
  • 内存:9472kb
  • [2023-10-02 16:32:16]
  • 提交

answer

#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC target("avx")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include <bits/stdc++.h>
using namespace std ;
const int N=2e3+7;
int f[N][N][2][2],R[N],pp[N];
int n,m; char s[N];
bitset<N>G[N][2][2],E,F;
void dfs(int u){
	if(n<0) return;
	if(u==m+1){
		n--; return;
	}
	R[pp[u]]=0; int flag=1;
	for(int i=1;i<=u;i++)
		if(!G[pp[i]][R[pp[i]]][R[pp[u]]][pp[u]]){
			flag=0; break;
		}
	if(flag) dfs(u+1);
	if(n<0) return;
	R[pp[u]]=1; flag=1;
	for(int i=1;i<=u;i++)
		if(!G[pp[i]][R[pp[i]]][R[pp[u]]][pp[u]]){
			flag=0; break;
		}
	if(flag) dfs(u+1);
	if(n<0) return;
}
namespace IO{
#define BUF_SIZE 100000
#define OUT_SIZE 100000
#define ll long long
    //fread->read

    bool IOerror=0;
    inline char nc(){
        static char buf[BUF_SIZE],*p1=buf+BUF_SIZE,*pend=buf+BUF_SIZE;
        if (p1==pend){
            p1=buf; pend=buf+fread(buf,1,BUF_SIZE,stdin);
            if (pend==p1){IOerror=1;return -1;}
            //{printf("IO error!\n");system("pause");for (;;);exit(0);}
        }
        return *p1++;
    }
    inline bool blank(char ch){return ch==' '||ch=='\n'||ch=='\r'||ch=='\t';}
    inline void read(int &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(ll &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (sign)x=-x;
    }
    inline void read(double &x){
        bool sign=0; char ch=nc(); x=0;
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        if (ch=='-')sign=1,ch=nc();
        for (;ch>='0'&&ch<='9';ch=nc())x=x*10+ch-'0';
        if (ch=='.'){
            double tmp=1; ch=nc();
            for (;ch>='0'&&ch<='9';ch=nc())tmp/=10.0,x+=tmp*(ch-'0');
        }
        if (sign)x=-x;
    }
    inline void read(char *s){
        char ch=nc();
        for (;blank(ch);ch=nc());
        if (IOerror)return;
        for (;!blank(ch)&&!IOerror;ch=nc())*s++=ch;
        *s=0;
    }
    inline void read(char &c){
        for (c=nc();blank(c);c=nc());
        if (IOerror){c=-1;return;}
    }
    //fwrite->write
    struct Ostream_fwrite{
        char *buf,*p1,*pend;
        Ostream_fwrite(){buf=new char[BUF_SIZE];p1=buf;pend=buf+BUF_SIZE;}
        void out(char ch){
            if (p1==pend){
                fwrite(buf,1,BUF_SIZE,stdout);p1=buf;
            }
            *p1++=ch;
        }
        void print(int x){
            static char s[15],*s1;s1=s;
            if (!x)*s1++='0';if (x<0)out('-'),x=-x;
            while(x)*s1++=x%10+'0',x/=10;
            while(s1--!=s)out(*s1);
        }
        void println(int x){
            static char s[15],*s1;s1=s;
            if (!x)*s1++='0';if (x<0)out('-'),x=-x;
            while(x)*s1++=x%10+'0',x/=10;
            while(s1--!=s)out(*s1); out('\n');
        }
        void print(ll x){
            static char s[25],*s1;s1=s;
            if (!x)*s1++='0';if (x<0)out('-'),x=-x;
            while(x)*s1++=x%10+'0',x/=10;
            while(s1--!=s)out(*s1);
        }
        void println(ll x){
            static char s[25],*s1;s1=s;
            if (!x)*s1++='0';if (x<0)out('-'),x=-x;
            while(x)*s1++=x%10+'0',x/=10;
            while(s1--!=s)out(*s1); out('\n');
        }
        void print(double x,int y){
            static ll mul[]={1,10,100,1000,10000,100000,1000000,10000000,100000000,
                             1000000000,10000000000LL,100000000000LL,1000000000000LL,10000000000000LL,
                             100000000000000LL,1000000000000000LL,10000000000000000LL,100000000000000000LL};
            if (x<-1e-12)out('-'),x=-x;x*=mul[y];
            ll x1=(ll)floor(x); if (x-floor(x)>=0.5)++x1;
            ll x2=x1/mul[y],x3=x1-x2*mul[y]; print(x2);
            if (y>0){out('.'); for (size_t i=1;i<y&&x3*mul[i]<mul[y];out('0'),++i); print(x3);}
        }
        void println(double x,int y){print(x,y);out('\n');}
        void print(char *s){while (*s)out(*s++);}
        void println(char *s){while (*s)out(*s++);out('\n');}
        void flush(){if (p1!=buf){fwrite(buf,1,p1-buf,stdout);p1=buf;}}
        ~Ostream_fwrite(){flush();}
    }Ostream;
    inline void print(int x){Ostream.print(x);}
    inline void println(int x){Ostream.println(x);}
    inline void print(char x){Ostream.out(x);}
    inline void println(char x){Ostream.out(x);Ostream.out('\n');}
    inline void print(ll x){Ostream.print(x);}
    inline void println(ll x){Ostream.println(x);}
    inline void print(double x,int y){Ostream.print(x,y);}
    inline void println(double x,int y){Ostream.println(x,y);}
    inline void print(char *s){Ostream.print(s);}
    inline void println(char *s){Ostream.println(s);}
    inline void println(){Ostream.out('\n');}
    inline void flush(){Ostream.flush();}
    inline void out(char c){Ostream.out(c);}
#undef ll
#undef OUT_SIZE
#undef BUF_SIZE
};
// using namespace IO;
signed main(){
	IO::read(n),IO::read(m);
	for(int i=1;i<=m;i++) pp[i]=i;
	random_shuffle(pp+1,pp+m+1);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			IO::read(s[j]);
			while(s[j]!='0'&&s[j]!='1') IO::read(s[j]);
		}
		E.reset();
		F.reset();
		for(int j=1;j<=m;j++) if(s[j]=='0') E[j]=1; else F[j]=1;
		for(int j=1;j<=m;j++) if(s[j]=='0') G[j][0][0]|=E,G[j][0][1]|=F;
		for(int j=1;j<=m;j++) if(s[j]=='1') G[j][1][0]|=E,G[j][1][1]|=F;
	}
	dfs(1);
	if(n<0){
		IO::print("-1"),IO::flush(); return 0;
	}
	for(int i=1;i<=m;i++) G[i][1][0][i]=G[i][0][1][i]=1;
	int D=0;
	for(int i=1;i<=m;i++)
		for(int x=0;x<=1;x++)
			for(int y=0;y<=1;y++)
				for(int j=i;j<=m;j++)
					if(!G[i][x][y][j]) D++;
	IO::println(D);
	for(int i=1;i<=m;i++)
		for(int x=0;x<=1;x++)
			for(int y=0;y<=1;y++)
				for(int j=i;j<=m;j++)
					if(!G[i][x][y][j]){
						IO::print(i-1),IO::out(' ');
						IO::print(j-1),IO::out(' ');
						IO::print((x^1)+2*(y^1)+1),IO::out('\n');
					}
	IO::flush();
	return 0;
}

/*
2
-3 0 1
3 0 1



*/

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 1ms
memory: 5788kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #2:

score: 0
Accepted
time: 1ms
memory: 7748kb

input:

3 3
101
011
111

output:

6
0 1 4
0 2 4
0 2 3
1 2 4
1 2 3
2 2 4

result:

ok Kout = 6, Kans = 6

Test #3:

score: 0
Accepted
time: 1ms
memory: 5692kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #4:

score: 0
Accepted
time: 0ms
memory: 5636kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #5:

score: 0
Accepted
time: 1ms
memory: 5692kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #6:

score: 0
Accepted
time: 0ms
memory: 5580kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #7:

score: 0
Accepted
time: 0ms
memory: 7804kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #8:

score: 0
Accepted
time: 1ms
memory: 5640kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #9:

score: 0
Accepted
time: 0ms
memory: 7744kb

input:

1 1
1

output:

1
0 0 4

result:

ok Kout = 1, Kans = 1

Test #10:

score: 0
Accepted
time: 1ms
memory: 5692kb

input:

1 1
0

output:

1
0 0 1

result:

ok Kout = 1, Kans = 1

Test #11:

score: 0
Accepted
time: 1ms
memory: 5576kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #12:

score: 0
Accepted
time: 1ms
memory: 5696kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #13:

score: 0
Accepted
time: 1ms
memory: 5716kb

input:

2 4
0111
0010

output:

15
0 2 4
0 1 3
0 2 3
0 3 3
0 0 1
0 1 1
0 2 1
0 3 1
1 2 4
1 3 2
1 2 3
1 3 3
2 2 4
2 3 4
2 3 2

result:

ok Kout = 15, Kans = 15

Test #14:

score: 0
Accepted
time: 1ms
memory: 5772kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #15:

score: 0
Accepted
time: 0ms
memory: 5580kb

input:

4 2
10
11
01
00

output:

0

result:

ok Kout = 0, Kans = 0

Test #16:

score: 0
Accepted
time: 1ms
memory: 5712kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #17:

score: 0
Accepted
time: 1ms
memory: 7740kb

input:

2 4
0010
1000

output:

15
0 2 4
0 1 2
0 3 2
0 1 1
0 2 1
0 3 1
1 3 2
1 2 3
1 3 3
1 1 1
1 2 1
1 3 1
2 3 2
2 3 1
3 3 1

result:

ok Kout = 15, Kans = 15

Test #18:

score: 0
Accepted
time: 1ms
memory: 7820kb

input:

2 5
11101
00000

output:

21
0 1 2
0 2 2
0 3 2
0 4 2
0 1 3
0 2 3
0 4 3
0 3 1
1 2 2
1 3 2
1 4 2
1 2 3
1 4 3
1 3 1
2 3 2
2 4 2
2 4 3
2 3 1
3 4 3
3 3 1
3 4 1

result:

ok Kout = 21, Kans = 21

Test #19:

score: 0
Accepted
time: 0ms
memory: 5636kb

input:

5 4
0010
1001
0011
0101
1011

output:

-1

result:

ok Kout = -1, Kans = -1

Test #20:

score: 0
Accepted
time: 1ms
memory: 5696kb

input:

3 2
01
00
10

output:

1
0 1 1

result:

ok Kout = 1, Kans = 1

Test #21:

score: 0
Accepted
time: 1ms
memory: 5576kb

input:

3 2
10
11
00

output:

1
0 1 2

result:

ok Kout = 1, Kans = 1

Test #22:

score: 0
Accepted
time: 1ms
memory: 5628kb

input:

2 1
0
1

output:

0

result:

ok Kout = 0, Kans = 0

Test #23:

score: 0
Accepted
time: 1ms
memory: 5788kb

input:

3 27
111010110011101010011110110
010001110100000110100101101
000011111000000010011111001

output:

-1

result:

ok Kout = -1, Kans = -1

Test #24:

score: 0
Accepted
time: 1ms
memory: 5776kb

input:

3 7
1000100
0001100
0101111

output:

39
0 3 4
0 4 4
0 2 2
0 4 3
0 1 1
0 2 1
0 3 1
0 5 1
0 6 1
1 4 4
1 2 2
1 5 2
1 6 2
1 3 3
1 4 3
1 5 3
1 6 3
1 2 1
2 4 4
2 3 3
2 4 3
2 5 3
2 6 3
2 2 1
2 3 1
2 4 1
2 5 1
2 6 1
3 4 4
3 5 2
3 6 2
3 4 3
4 4 4
4 5 4
4 6 4
4 5 2
4 6 2
5 6 2
5 6 3

result:

ok Kout = 39, Kans = 39

Test #25:

score: 0
Accepted
time: 0ms
memory: 3688kb

input:

1 19
1010110011001101000

output:

532
0 0 4
0 1 4
0 2 4
0 3 4
0 4 4
0 5 4
0 6 4
0 7 4
0 8 4
0 9 4
0 10 4
0 11 4
0 12 4
0 13 4
0 14 4
0 15 4
0 16 4
0 17 4
0 18 4
0 1 2
0 2 2
0 3 2
0 4 2
0 5 2
0 6 2
0 7 2
0 8 2
0 9 2
0 10 2
0 11 2
0 12 2
0 13 2
0 14 2
0 15 2
0 16 2
0 17 2
0 18 2
0 2 3
0 4 3
0 5 3
0 8 3
0 9 3
0 12 3
0 13 3
0 15 3
0 1 1...

result:

ok Kout = 532, Kans = 532

Test #26:

score: 0
Accepted
time: 1ms
memory: 5744kb

input:

5 32
10101101001001001101111100100110
00110110010111010101011000011010
01010101110100000110001000010100
11010011000110101101110001011111
00111001110011110000000010000111

output:

-1

result:

ok Kout = -1, Kans = -1

Test #27:

score: 0
Accepted
time: 0ms
memory: 5712kb

input:

3 12
110010101000
110001011000
110101011001

output:

145
0 0 4
0 1 4
0 2 4
0 3 4
0 4 4
0 5 4
0 6 4
0 7 4
0 8 4
0 9 4
0 10 4
0 11 4
0 1 2
0 2 2
0 3 2
0 4 2
0 5 2
0 6 2
0 7 2
0 8 2
0 9 2
0 10 2
0 11 2
0 1 3
0 8 3
0 2 1
0 9 1
0 10 1
1 1 4
1 2 4
1 3 4
1 4 4
1 5 4
1 6 4
1 7 4
1 8 4
1 9 4
1 10 4
1 11 4
1 2 2
1 3 2
1 4 2
1 5 2
1 6 2
1 7 2
1 8 2
1 9 2
1 10 2
...

result:

ok Kout = 145, Kans = 145

Test #28:

score: 0
Accepted
time: 1ms
memory: 5720kb

input:

3 25
1110100100011100101100111
0100000001011101101010101
0111110111111001001110111

output:

-1

result:

ok Kout = -1, Kans = -1

Test #29:

score: 0
Accepted
time: 1ms
memory: 5704kb

input:

1 5
10110

output:

35
0 0 4
0 1 4
0 2 4
0 3 4
0 4 4
0 1 2
0 2 2
0 3 2
0 4 2
0 2 3
0 3 3
0 1 1
0 4 1
1 2 4
1 3 4
1 4 2
1 2 3
1 3 3
1 4 3
1 1 1
1 2 1
1 3 1
1 4 1
2 2 4
2 3 4
2 4 4
2 3 2
2 4 2
2 3 3
2 4 1
3 3 4
3 4 4
3 4 2
3 4 1
4 4 1

result:

ok Kout = 35, Kans = 35

Test #30:

score: 0
Accepted
time: 1ms
memory: 5808kb

input:

5 17
01011100010100110
01001101111011001
00100111001101010
10101000001010110
00101011010010001

output:

-1

result:

ok Kout = -1, Kans = -1

Test #31:

score: 0
Accepted
time: 1ms
memory: 7700kb

input:

3 30
010100010011100011010001010100
011111100101001100010101010010
011000010111111111000101101110

output:

-1

result:

ok Kout = -1, Kans = -1

Test #32:

score: 0
Accepted
time: 1ms
memory: 5732kb

input:

5 30
110010101001001100010110010000
011011111000011001101000100000
110101010111000000100100111000
001111011110101101101001101011
101100001101011110101010110000

output:

-1

result:

ok Kout = -1, Kans = -1

Test #33:

score: 0
Accepted
time: 0ms
memory: 5712kb

input:

10 10
0110101111
1100100000
1000101100
1000010101
1001011101
1011101101
1011111011
0101010000
0111011010
1111010110

output:

-1

result:

ok Kout = -1, Kans = -1

Test #34:

score: 0
Accepted
time: 0ms
memory: 5728kb

input:

9 10
1000001101
0110010110
1011101111
1010001110
1110001000
1001110110
1101010010
0001011111
1000010100

output:

-1

result:

ok Kout = -1, Kans = -1

Test #35:

score: 0
Accepted
time: 1ms
memory: 5768kb

input:

3 5
11111
01000
01100

output:

18
0 1 4
0 3 2
0 4 2
0 1 3
0 2 3
0 3 3
0 4 3
1 1 4
1 2 4
1 3 4
1 4 4
1 2 2
1 3 2
1 4 2
2 3 2
2 4 2
3 4 2
3 4 3

result:

ok Kout = 18, Kans = 18

Test #36:

score: 0
Accepted
time: 1ms
memory: 5592kb

input:

7 9
000010100
101001100
110010111
000000110
100010101
101000100
101101100

output:

-1

result:

ok Kout = -1, Kans = -1

Test #37:

score: 0
Accepted
time: 1ms
memory: 5648kb

input:

1 4
0000

output:

22
0 1 2
0 2 2
0 3 2
0 1 3
0 2 3
0 3 3
0 0 1
0 1 1
0 2 1
0 3 1
1 2 2
1 3 2
1 2 3
1 3 3
1 1 1
1 2 1
1 3 1
2 3 2
2 3 3
2 2 1
2 3 1
3 3 1

result:

ok Kout = 22, Kans = 22

Test #38:

score: 0
Accepted
time: 1ms
memory: 5676kb

input:

9 8
10011110
10111101
11001010
01000101
10110011
00101001
00101100
11010110
01000000

output:

-1

result:

ok Kout = -1, Kans = -1

Test #39:

score: 0
Accepted
time: 1ms
memory: 5636kb

input:

3 10
0000000111
1011011111
0101111010

output:

-1

result:

ok Kout = -1, Kans = -1

Test #40:

score: 0
Accepted
time: 1ms
memory: 5636kb

input:

2 1
1
0

output:

0

result:

ok Kout = 0, Kans = 0

Test #41:

score: 0
Accepted
time: 1ms
memory: 5708kb

input:

1 5
00110

output:

35
0 2 4
0 3 4
0 1 2
0 4 2
0 1 3
0 2 3
0 3 3
0 4 3
0 0 1
0 1 1
0 2 1
0 3 1
0 4 1
1 2 4
1 3 4
1 4 2
1 2 3
1 3 3
1 4 3
1 1 1
1 2 1
1 3 1
1 4 1
2 2 4
2 3 4
2 4 4
2 3 2
2 4 2
2 3 3
2 4 1
3 3 4
3 4 4
3 4 2
3 4 1
4 4 1

result:

ok Kout = 35, Kans = 35

Test #42:

score: 0
Accepted
time: 1ms
memory: 5680kb

input:

6 9
100101111
100001110
100101010
001101000
101100010
010101110

output:

-1

result:

ok Kout = -1, Kans = -1

Test #43:

score: 0
Accepted
time: 3ms
memory: 6396kb

input:

6 836
001111110001001001101010101010011100010100100100111110110100101000100100000000011101110001011100111111111001101111111101101110010011000100100111111101011010101101011101010000100011100011000011111011011110000001010101001101110100001111111001000110111000010110001100110010010000101011001010101100...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #44:

score: 0
Accepted
time: 112ms
memory: 7520kb

input:

1 1680
00110010011001010101000101001110100010100110000110011101101101011011011011011011000000100100001111110111011001000010100101111110011000011110001000000001001010010110001011101000000110011010000001101010010000101111000010110001001010000010001010110000110111011011001011010011100111110000100110110...

output:

4232760
0 2 4
0 3 4
0 6 4
0 9 4
0 10 4
0 13 4
0 15 4
0 17 4
0 19 4
0 23 4
0 25 4
0 28 4
0 29 4
0 30 4
0 32 4
0 36 4
0 38 4
0 41 4
0 42 4
0 47 4
0 48 4
0 51 4
0 52 4
0 53 4
0 55 4
0 56 4
0 58 4
0 59 4
0 61 4
0 63 4
0 64 4
0 66 4
0 67 4
0 69 4
0 70 4
0 72 4
0 73 4
0 75 4
0 76 4
0 78 4
0 79 4
0 86 4
0 ...

result:

ok Kout = 4232760, Kans = 4232760

Test #45:

score: 0
Accepted
time: 0ms
memory: 6312kb

input:

5 525
010011011010110111000101111001010011110110100011110111000110010010000011011011110001110100110101101111111001100010010011011011011101110010011011001111110100010011011001010111011001100011001000101100111000000100010100011011011110101010000011101110001001000000100101000000101011101010110101010110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #46:

score: 0
Accepted
time: 8ms
memory: 6720kb

input:

9 1369
10111110110000010001000001110000001000010000101111010111111000100001001011101000101011000111001000010110010100011001110101100010000010000010100010011100110011000011110001001001010100010100001111111000111110100100010000100100110111110101100011010100000011000011010111111101011001011001010010110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #47:

score: 0
Accepted
time: 9ms
memory: 6800kb

input:

7 1509
10100001100101000101100011100001010001111101001010100101000010000100010000100110001011000011111000111100011100000110100100011010011111011100111010101011110111011011100100101110011000110111100101101011010101100011101011110001011101001011010100000011001001110100111101101001100110101111011010011...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #48:

score: 0
Accepted
time: 6ms
memory: 6128kb

input:

1 354
101000111100100010011000000111001111100100100101111010100100101010111001011110011010111111010010101111101101101010100011010000011011010101000011010000001101110011011000101101111011111001011010111100100001100000110000110011101011010011110011001100101100011101100010101001100101110011001011001011...

output:

187797
0 0 4
0 1 4
0 2 4
0 3 4
0 4 4
0 5 4
0 6 4
0 7 4
0 8 4
0 9 4
0 10 4
0 11 4
0 12 4
0 13 4
0 14 4
0 15 4
0 16 4
0 17 4
0 18 4
0 19 4
0 20 4
0 21 4
0 22 4
0 23 4
0 24 4
0 25 4
0 26 4
0 27 4
0 28 4
0 29 4
0 30 4
0 31 4
0 32 4
0 33 4
0 34 4
0 35 4
0 36 4
0 37 4
0 38 4
0 39 4
0 40 4
0 41 4
0 42 4
0 ...

result:

ok Kout = 187797, Kans = 187797

Test #49:

score: 0
Accepted
time: 4ms
memory: 6740kb

input:

5 1006
00111100011111100001101011101101000101000011011000111111110010111011001101010000100011001000000111001011010000001110010000101000010111100101100101101000110000011011101010111110101110100110000011001000010000011111000001011111101010110011100110010011010000000000100000111101000001000100101110100...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #50:

score: 0
Accepted
time: 10ms
memory: 6432kb

input:

9 1851
11000110100010011010000110010000010111101010100110011010100101110011100000101101001010000010001011111110100001101000001101111011011011011110010110000111001101110011001011111001110001011101100110111111100101100101000110010001011001100101010111100000101111010110010000110111010100011010111101110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #51:

score: 0
Accepted
time: 3ms
memory: 6168kb

input:

7 695
001100011101000101000011101100000101000000010110110101110110100101010100100111101110100100110101110100111000011000000101111101010100010010101011100101111001100001101111000111000111010110101101001111110111110001010011011111110111111010101010100100111010101010100111110011001100101100110010111101...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #52:

score: 0
Accepted
time: 1ms
memory: 5940kb

input:

8 231
010111111111010000001100101001011111011010100101010100111010100110111011111111101110001100001001101110001001000000001110010010010110011001011110100110110110101100101110101100101011000001101111101001110000101110110010000100111101010
00010011100001101010000101100000110001010100100010110011011111...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #53:

score: 0
Accepted
time: 79ms
memory: 6456kb

input:

1751 1586
01101110101110010111101111101010000000001010101101111100000001001100010101101011011111100010010111010010010010111101000011101101010110011100010001111110110011001111111111010000101011010111101110010101010011100110001111101111010000001111101111101011110100011101101100000011100110100110000000...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #54:

score: 0
Accepted
time: 41ms
memory: 6864kb

input:

1879 942
000110000110010111010100001100110100110111110010011011100000001111011000110000000001110001001111110000010000110101111011101001001110000101111111101100101100110111111011001011001101101000011000000011110000011111111000010111000000001011101101110100011111101000110101000010011110101011110001111...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #55:

score: 0
Accepted
time: 14ms
memory: 8984kb

input:

599 1083
111111011111001001100010010111010010011010111001100010011000101111110011111111000001001000000011110101011100100100000000001010100100011010010111010111011101010101010011001101100101011001110010111100000110111001000000100001111110000011001000100111100000110100100110010001011100101101111000110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #56:

score: 0
Accepted
time: 41ms
memory: 6036kb

input:

727 1927
001101011110100000000001100011110010101101011100011010001000111100001001110000111101111101101111111101011111110111010100110000100011110110001110011000101001001001001100101110111111111000011110111110010111110111111101000010011011000010111011010110100110101010100111010011110101000111101000001...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #57:

score: 0
Accepted
time: 4ms
memory: 6556kb

input:

151 772
0011100000111101101010100111100010111101101001001010101000110100000010101010011001011010111110011100101101011110010000101110111011001110111110110011011001111101010011010110111011010011011001111101001100111001110110111001011010110100000000010101110000101011101001001110111011000000100100010000...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #58:

score: 0
Accepted
time: 7ms
memory: 6108kb

input:

279 912
1101101011000001010100111010110010110011000101001111100000100001110011010010001101010100000111011101111010100010100011001010010100110111000000001010010110111000110100010011101010011111010001011011100011011101101100110001111011101010000011000111001010001010110110000111001001100100100111100001...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #59:

score: 0
Accepted
time: 15ms
memory: 6224kb

input:

1704 460
011100111111111110111100000010110110000111101010010100101100011011110101100111010000101111110001100100110111010100110011000011001100111101110110001010010010111110110000000000100111110110011000011110010101100101011011001001111010110010110011110011011100110111010111110111100010110010000101110...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #60:

score: 0
Accepted
time: 11ms
memory: 6240kb

input:

1128 409
110010110101001111011001011001011000001111001001010001010110111111101101000111111110110110000111100001000010110010110010111001101111010010100000100000011100110010001010010010010000101100011010010111011110111010010010010110101100001001111111100111100000111010010001101010010011100010001110001...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #61:

score: 0
Accepted
time: 39ms
memory: 6756kb

input:

1256 1253
00001111110000100001010011101010110110011010100000000010110000001011100101111001010101010001001100100011010101101100110100101011100100101101000111001010001010011101100000101101110100111100111101100100110100110010010000011001111100111111011111101101001111101000111111100010101111101111001001...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #62:

score: 0
Accepted
time: 37ms
memory: 6860kb

input:

1537 1004
11100001111000100101010000101010000001010011001001110010100111110000000100110110010100111001010100001110001101111111111010001101001100110100110011100010001001110111111110110110111111000110011100000101100010110111110000000110011010001100100111111111011100110000101110010111111011110101000111...

output:

-1

result:

ok Kout = -1, Kans = -1

Test #63:

score: 0
Accepted
time: 2273ms
memory: 6284kb

input:

2000 2000
00111010010010101011100101011110001000011110110110001001100001011010001110101110010111011100100111000011111100100110100110110000111111110010111100011110000000000010100010000001000100111000001110111111011101111010100110001111100111001100001001101011011101001011101000111011001011000101111101...

output:

2001000
0 2 4
0 3 4
0 6 4
0 9 4
0 12 4
0 14 4
0 16 4
0 18 4
0 19 4
0 20 4
0 25 4
0 27 4
0 28 4
0 30 4
0 34 4
0 39 4
0 41 4
0 48 4
0 52 4
0 56 4
0 64 4
0 70 4
0 71 4
0 72 4
0 76 4
0 77 4
0 78 4
0 81 4
0 84 4
0 87 4
0 88 4
0 95 4
0 96 4
0 97 4
0 104 4
0 105 4
0 107 4
0 113 4
0 119 4
0 123 4
0 129 4
0 ...

result:

ok Kout = 2001000, Kans = 2001000

Test #64:

score: 0
Accepted
time: 2280ms
memory: 6364kb

input:

2000 2000
11101000100100110110110111100101111011101100110011001100010000010100011100000001100000111100000101101011000011010011111100111010101001101001110011110100011111011000011100000111010101111001001011000111011010011110100011001111100000001111110010111001000010000000000111100101011001011100111101...

output:

2001000
0 4 4
0 11 4
0 17 4
0 21 4
0 23 4
0 25 4
0 41 4
0 44 4
0 57 4
0 60 4
0 97 4
0 98 4
0 102 4
0 103 4
0 115 4
0 119 4
0 126 4
0 128 4
0 136 4
0 145 4
0 147 4
0 159 4
0 160 4
0 165 4
0 177 4
0 197 4
0 198 4
0 204 4
0 208 4
0 233 4
0 236 4
0 242 4
0 264 4
0 281 4
0 283 4
0 284 4
0 290 4
0 296 4
0...

result:

ok Kout = 2001000, Kans = 2001000

Test #65:

score: 0
Accepted
time: 2450ms
memory: 7120kb

input:

2000 2000
11000010000110011011110010001111100101100111010111000100000000001001110111101110111000011010101101100011100101001101100100101100111001100100101010100101000100000101110011110001101101001001101101011110011101100000100111111100110011010011100001010001111001001111000110111011111001001010001101...

output:

2001000
0 1 4
0 2 4
0 3 4
0 11 4
0 12 4
0 15 4
0 16 4
0 18 4
0 19 4
0 20 4
0 21 4
0 24 4
0 27 4
0 29 4
0 30 4
0 31 4
0 32 4
0 33 4
0 35 4
0 37 4
0 38 4
0 42 4
0 43 4
0 44 4
0 47 4
0 48 4
0 49 4
0 52 4
0 56 4
0 59 4
0 63 4
0 64 4
0 67 4
0 68 4
0 69 4
0 71 4
0 72 4
0 73 4
0 74 4
0 75 4
0 76 4
0 77 4
0...

result:

ok Kout = 2001000, Kans = 2001000

Test #66:

score: 0
Accepted
time: 2551ms
memory: 7696kb

input:

2000 2000
10000000000101110100100101010010001110001100110100111110010000100100000100000000010100000001100010100101111011011101111010111110001100100001100011011101101101101001001010010100101011010001010110000000011011000110000111110011111101011111111110010110011111001010000110010010110110001110110101...

output:

2001000
0 15 4
0 27 4
0 36 4
0 40 4
0 41 4
0 44 4
0 45 4
0 52 4
0 55 4
0 57 4
0 81 4
0 83 4
0 85 4
0 101 4
0 104 4
0 105 4
0 108 4
0 115 4
0 116 4
0 120 4
0 124 4
0 129 4
0 134 4
0 144 4
0 152 4
0 160 4
0 163 4
0 166 4
0 169 4
0 176 4
0 201 4
0 202 4
0 204 4
0 205 4
0 217 4
0 223 4
0 225 4
0 227 4
0...

result:

ok Kout = 2001000, Kans = 2001000

Test #67:

score: 0
Accepted
time: 2358ms
memory: 6732kb

input:

2000 2000
00100000000100010100101000010011001001111100100011100001100100111010000001000110100011011101010011100101101011011011011110100010011011101101111111000010001001111111111111100111100010101100101000100101011000011010100100111110100011100011110000111101011000010111010011101100101000010010001001...

output:

2001000
0 55 4
0 66 4
0 91 4
0 161 4
0 185 4
0 249 4
0 328 4
0 365 4
0 412 4
0 473 4
0 591 4
0 613 4
0 620 4
0 761 4
0 769 4
0 873 4
0 917 4
0 937 4
0 1000 4
0 1040 4
0 1130 4
0 1176 4
0 1297 4
0 1423 4
0 1506 4
0 1547 4
0 1570 4
0 1602 4
0 1608 4
0 1627 4
0 1649 4
0 1663 4
0 1745 4
0 1760 4
0 1770 ...

result:

ok Kout = 2001000, Kans = 2001000

Test #68:

score: 0
Accepted
time: 2387ms
memory: 7876kb

input:

2000 2000
00100101010000000000000111001011100001100111111110111110001000110111010001001111000010110111111011001011110101000011101110000110010010101100101000111111001110011100111100011110010100011000000011100000101010011001111001010000110100000101110010100101111010100100101010001100100000110111111111...

output:

2001000
0 30 4
0 37 4
0 43 4
0 44 4
0 45 4
0 46 4
0 47 4
0 50 4
0 51 4
0 53 4
0 54 4
0 58 4
0 66 4
0 67 4
0 76 4
0 79 4
0 84 4
0 87 4
0 89 4
0 90 4
0 91 4
0 92 4
0 93 4
0 94 4
0 96 4
0 102 4
0 104 4
0 105 4
0 115 4
0 116 4
0 118 4
0 120 4
0 125 4
0 132 4
0 136 4
0 137 4
0 146 4
0 147 4
0 149 4
0 150...

result:

ok Kout = 2001000, Kans = 2001000

Test #69:

score: 0
Accepted
time: 2277ms
memory: 6816kb

input:

2000 2000
01111100110010011110000111001100000111000000101101110101111011011110100011101001110101011100110110110011100000100111010010010010110010111111010111011111111001001001001110111011010011000000011010010110011111000111011110101000011010100101100010100101101000100010111001101101001010011000100100...

output:

2001000
0 4 4
0 9 4
0 17 4
0 25 4
0 28 4
0 35 4
0 47 4
0 49 4
0 55 4
0 80 4
0 81 4
0 92 4
0 114 4
0 117 4
0 129 4
0 132 4
0 134 4
0 141 4
0 145 4
0 148 4
0 149 4
0 157 4
0 197 4
0 203 4
0 204 4
0 205 4
0 213 4
0 265 4
0 279 4
0 296 4
0 302 4
0 304 4
0 314 4
0 315 4
0 321 4
0 324 4
0 330 4
0 331 4
0 ...

result:

ok Kout = 2001000, Kans = 2001000

Test #70:

score: 0
Accepted
time: 2305ms
memory: 6768kb

input:

2000 2000
10111110101111011000011101110000100100110001110000100010110010101111110001100010100101000100101101101010111001001111000010000110111100111100111100010000101100111010011111011110111010111110011111111010000001101101010111011001000011111111110111111100110111001011010100101100010000001111000010...

output:

2001000
0 1 4
0 7 4
0 9 4
0 17 4
0 20 4
0 22 4
0 24 4
0 25 4
0 26 4
0 29 4
0 31 4
0 32 4
0 42 4
0 49 4
0 53 4
0 55 4
0 65 4
0 69 4
0 70 4
0 76 4
0 78 4
0 82 4
0 84 4
0 98 4
0 99 4
0 100 4
0 101 4
0 103 4
0 105 4
0 108 4
0 111 4
0 115 4
0 121 4
0 124 4
0 125 4
0 126 4
0 127 4
0 139 4
0 144 4
0 150 4
...

result:

ok Kout = 2001000, Kans = 2001000

Test #71:

score: 0
Accepted
time: 2450ms
memory: 9472kb

input:

2000 2000
11100100001101010101010010010001010011100011010100110111000100101110000010000000111100011110001101000000110000101011001010011000000101000100110010111100100100111011110011000010001000101011111100110000111001000111101110001111011011000011100100101011110100111000010000100101100100111010010100...

output:

2001000
0 4 4
0 6 4
0 11 4
0 23 4
0 27 4
0 29 4
0 30 4
0 37 4
0 39 4
0 40 4
0 41 4
0 49 4
0 57 4
0 58 4
0 63 4
0 67 4
0 71 4
0 73 4
0 74 4
0 76 4
0 77 4
0 78 4
0 84 4
0 86 4
0 87 4
0 91 4
0 92 4
0 96 4
0 97 4
0 99 4
0 107 4
0 108 4
0 111 4
0 112 4
0 116 4
0 119 4
0 122 4
0 125 4
0 126 4
0 127 4
0 12...

result:

ok Kout = 2001000, Kans = 2001000

Test #72:

score: 0
Accepted
time: 2238ms
memory: 5912kb

input:

2000 2000
01011010010100100110011111110101001010000110000100101000010010111100101001010010101111001011011101111010010111110111111111100000111000001110001101010010001010000110110011110001010110011111000100111100010111000111000110111011010011111100100010011011000000010101001010110010101010001001101001...

output:

2001000
0 4 4
0 11 4
0 17 4
0 18 4
0 22 4
0 23 4
0 24 4
0 26 4
0 27 4
0 29 4
0 31 4
0 36 4
0 41 4
0 42 4
0 60 4
0 62 4
0 64 4
0 70 4
0 80 4
0 82 4
0 83 4
0 85 4
0 88 4
0 90 4
0 91 4
0 93 4
0 94 4
0 97 4
0 98 4
0 100 4
0 105 4
0 108 4
0 109 4
0 116 4
0 120 4
0 129 4
0 130 4
0 136 4
0 137 4
0 142 4
0 ...

result:

ok Kout = 2001000, Kans = 2001000