QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#524048#8675. Scheduleucup-team052AC ✓1ms4200kbC++231.9kb2024-08-19 09:16:052024-08-19 09:16:05

Judging History

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

  • [2024-08-19 09:16:05]
  • 评测
  • 测评结果:AC
  • 用时:1ms
  • 内存:4200kb
  • [2024-08-19 09:16:05]
  • 提交

answer

    #include<bits/stdc++.h>
    #define rep(i,a,b) for(int i=(a);i<=(b);++i)
    #define per(i,a,b) for(int i=(a);i>=(b);--i)
    #define pb push_back
    #define eb emplace_back
    #define SZ(x) ((int)(x).size())
    #define D(...) fprintf(stderr,__VA_ARGS__)
    using namespace std;
    using LL=long long;
    unsigned long long C[60][60];
    #ifdef xay5421
    int vis[1005][2][1005][2];
    #endif
    int main(){
    #ifdef xay5421
    	freopen("a.in","r",stdin);
    #endif
    	int n,w;
    	cin>>n>>w;
    	rep(i,0,59){
    		C[i][0]=1;
    		rep(j,1,i){
    			C[i][j]=C[i-1][j-1]+C[i-1][j];
    		}
    	}
    	int x=1;
    	while(C[x][x/2]<n)++x;
    	int flag=0;
    	if (C[x][x/2-1]>=n){
    		flag=1;
    	}
    	vector<int>v;
    	rep(i,0,(1<<x)-1){
    		if(__builtin_popcount(i)==x/2-flag){
    			v.push_back(i);
    		}
    	}
    	rep(i,0,x-1){
    		rep(j,i,SZ(v)-1){
    			if(~v[j]>>(i>>1)&1){
    				swap(v[i],v[j]);
    				break;
    			}
    		}
    	}
    	// D("x=%d\n",x);
    	vector<string>s(x);
    	rep(i,0,x-1){
    		rep(j,0,n-1){
    			s[i].push_back(v[j]>>i&1?'1':'2');
    		}
    	}
    	{
    		if((~x&1)&&!flag){
    			s.push_back("");
    			rep(j,0,n-1)s.back().push_back('2');
    			x+=1;
    		}
    		s.push_back("");
    		rep(j,0,n-1)s.back().push_back('1');
    		x+=1;
    	}
    	if(w<x){
    		puts("infinity");
    		exit(0);
    	}
    #ifdef xay5421
    	for(int i=0;i<x;i++)
    	{
    		for(int j=0;j<n;j++) for(int k=j+1;k<n;k++) vis[j][s[i][j]-'1'][k][s[i][k]-'1']=1;
    	}
    	for(int i=0;i<n;i++) for(int c=0;c<2;c++)
    	{
    		for(int j=i+1;j<n;j++) for(int d=0;d<2;d++) printf("%d",vis[i][c][j][d]);
    	}
    	cout<<"\n";
    #endif
    	
    	printf("%d\n",x);
    	rep(i,0,w-1){
    		cout<<s[i%x]<<'\n';
    	}
    	return 0;
    }

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3660kb

input:

4 4

output:

infinity

result:

ok infinity

Test #2:

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

input:

3 4

output:

4
221
122
212
111

result:

ok 

Test #3:

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

input:

4 15

output:

5
2212
1222
2122
2221
1111
2212
1222
2122
2221
1111
2212
1222
2122
2221
1111

result:

ok 

Test #4:

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

input:

5 52

output:

6
22111
11221
12212
21122
22222
11111
22111
11221
12212
21122
22222
11111
22111
11221
12212
21122
22222
11111
22111
11221
12212
21122
22222
11111
22111
11221
12212
21122
22222
11111
22111
11221
12212
21122
22222
11111
22111
11221
12212
21122
22222
11111
22111
11221
12212
21122
22222
11111
22111
1122...

result:

ok 

Test #5:

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

input:

10 52

output:

6
2211121222
1122122122
1221212212
2112212221
2222221111
1111111111
2211121222
1122122122
1221212212
2112212221
2222221111
1111111111
2211121222
1122122122
1221212212
2112212221
2222221111
1111111111
2211121222
1122122122
1221212212
2112212221
2222221111
1111111111
2211121222
1122122122
1221212212
2...

result:

ok 

Test #6:

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

input:

11 52

output:

7
22111122221
11221221222
12212212122
21122212212
22222121112
22222222221
11111111111
22111122221
11221221222
12212212122
21122212212
22222121112
22222222221
11111111111
22111122221
11221221222
12212212122
21122212212
22222121112
22222222221
11111111111
22111122221
11221221222
12212212122
2112221221...

result:

ok 

Test #7:

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

input:

15 52

output:

7
221111222212222
112212212221222
122122121222122
211222122122212
222221211122221
222222222211111
111111111111111
221111222212222
112212212221222
122122121222122
211222122122212
222221211122221
222222222211111
111111111111111
221111222212222
112212212221222
122122121222122
211222122122212
2222212111...

result:

ok 

Test #8:

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

input:

16 52

output:

8
2211111122112122
1122111212121212
1111221221211221
1212212111222111
2121122111222222
2222222222111111
2222222222222222
1111111111111111
2211111122112122
1122111212121212
1111221221211221
1212212111222111
2121122111222222
2222222222111111
2222222222222222
1111111111111111
2211111122112122
112211121...

result:

ok 

Test #9:

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

input:

35 52

output:

8
22111111221121221222112122122212222
11221112121212122122121212212221222
11112212212112212212211221221222122
12122121112221112221222111222122212
21211221112222221111222222111122221
22222222221111111111222222222211111
22222222222222222222111111111111111
11111111111111111111111111111111111
2211111122...

result:

ok 

Test #10:

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

input:

36 52

output:

9
221111112211212212221121221222122221
112211111222121221221212122122212221
111122122121122122122112212212221222
121221221112211122212221112221222122
212112221112222211112222221111222212
222222212221111111112222222222111112
222222222222222222221111111111111112
222222222222222222222222222222222221
11...

result:

ok 

Test #11:

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

input:

56 52

output:

9
22111111221121221222112122122212222112122122212222122222
11221111122212122122121212212221222121212212221222212222
11112212212112212212211221221222122211221221222122221222
12122122111221112221222111222122212222111222122212222122
21211222111222221111222222111122221222222111122221222212
2222222122211...

result:

ok 

Test #12:

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

input:

57 52

output:

10
221111111112122111211212211212212221112112122112122122211
112211111121212112112121212121221221121121212121212212212
111122111211221121121122121122122121211211221211221221221
111111221222111211122211122211122212111222111222111222122
121221212111111222211111122222211112222111111222222111122
2121121...

result:

ok 

Test #13:

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

input:

126 52

output:

10
221111111112122111211212211212212221112112122112122122211212212221222211121121221121221222112122122212222112122122212222122222
112211111121212112112121212121221221121121212121212212212121221222122211211212121212122122121212212221222121212212221222212222
1111221112112211211211221211221221212112112...

result:

ok 

Test #14:

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

input:

127 52

output:

11
2211111111121221112112122112122122211121121221121221222112122122212222111211212211212212221121221222122221121221222122221222221
1122111111212121121121212121212212211211212121212122122121212212221222112112121212121221221212122122212221212122122212222122221
11112211111122122112112212112212212121121...

result:

ok 

Test #15:

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

input:

792 52

output:

13
221111111111112112122111121112112122111211212211212212221111211121121221112112122112122122211121121221121221222112122122212222111121112112122111211212211212212221112112122112122122211212212221222211121121221121221222112122122212222112122122212222122222111121112112122111211212211212212221112112122...

result:

ok 

Test #16:

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

input:

793 52

output:

14
221111111111111112111211212211111211112111211212211112111211212211121121221121221222111112111121112112122111121112112122111211212211212212221111211121121221112112122112122122211121121221121221222112122122212222111112111121112112122111121112112122111211212211212212221111211121121221112112122112122...

result:

ok 

Test #17:

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

input:

6435 52

output:

16
221111111111111111112111121112112122111111211111211112111211212211111211112111211212211112111211212211121121221121221222111111211111211112111211212211111211112111211212211112111211212211121121221121221222111112111121112112122111121112112122111211212211212212221111211121121221112112122112122122211...

result:

ok 

Test #18:

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

input:

6436 52

output:

17
221111111111111111112111121112112122111111211111211112111211212211111211112111211212211112111211212211121121221121221222111111211111211112111211212211111211112111211212211112111211212211121121221121221222111112111121112112122111121112112122111211212211212212221111211121121221112112122112122122211...

result:

ok 

Test #19:

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

input:

792 10

output:

infinity

result:

ok infinity

Test #20:

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

input:

5000 52

output:

16
221111111111111112111211212211111211112111211212211112111211212211121121221121221222111112111121112112122111121112112122111211212211212212221111211121121221112112122112122122211121121221121221222112122122212222111112111121112112122111121112112122111211212211212212221111211121121221112112122112122...

result:

ok 

Test #21:

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

input:

10000 52

output:

17
221111111111111111112111121112112122111111211111211112111211212211111211112111211212211112111211212211121121221121221222111111211111211112111211212211111211112111211212211112111211212211121121221121221222111112111121112112122111121112112122111211212211212212221111211121121221112112122112122122211...

result:

ok 

Test #22:

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

input:

2 3

output:

infinity

result:

ok infinity

Test #23:

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

input:

3 3

output:

infinity

result:

ok infinity

Test #24:

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

input:

4 5

output:

5
2212
1222
2122
2221
1111

result:

ok 

Test #25:

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

input:

5 5

output:

infinity

result:

ok infinity

Test #26:

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

input:

11 6

output:

infinity

result:

ok infinity

Test #27:

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

input:

11 7

output:

7
22111122221
11221221222
12212212122
21122212212
22222121112
22222222221
11111111111

result:

ok 

Test #28:

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

input:

127 10

output:

infinity

result:

ok infinity

Test #29:

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

input:

6436 16

output:

infinity

result:

ok infinity

Test #30:

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

input:

6436 17

output:

17
221111111111111111112111121112112122111111211111211112111211212211111211112111211212211112111211212211121121221121221222111111211111211112111211212211111211112111211212211112111211212211121121221121221222111112111121112112122111121112112122111211212211212212221111211121121221112112122112122122211...

result:

ok 

Extra Test:

score: 0
Extra Test Passed