QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#422019#2973. 宝牌一大堆rzh123100 ✓312ms4264kbC++232.4kb2024-05-26 16:39:052024-05-26 16:39:05

Judging History

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

  • [2024-05-26 16:39:05]
  • 评测
  • 测评结果:100
  • 用时:312ms
  • 内存:4264kb
  • [2024-05-26 16:39:05]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const int V=37,p2[6]={1,2,4,8,16,32},cc[5][5]={{1},{1,1},{1,2,1},{1,3,3,1},{1,4,6,4,1}};
ll ans{0ll};
int a[V];
bool key[V];
inline int getid(const string &s){
	switch(s.back()){
		case 'm':return s[0]-48; case 'p':return s[0]-48+9;
		case 's':return s[0]-48+18; case 'E':return 28; case 'S':return 29;
		case 'W':return 30; case 'N':return 31; case 'Z':return 32; case 'B':return 33; case 'F':return 34;
	} return 0;
}
inline void getcard(int id,char &ty,int &x){
	if(id<=9) ty='m',x=id;
	else if(id<=18) ty='p',x=id-9;
	else if(id<=27) ty='s',x=id-18;
	else ty="ESWNZBF"[id-28],x=0;
}
template <typename T>
inline void upd(T &a,T b){a=max(a,b);}
void solve1(){  // 3*4+2
	static long long f[V][16][2][5][5];
	memset(f,0,sizeof f),f[0][0][0][0][0]=1;
	for(int i{1};i<=34;++i){
		char ty;int idx; getcard(i,ty,idx);
		for(int j{0};j<=14&&j<=4*(i-1);++j)
			for(int k:{0,1}) for(int l:{0,1,2,3,4}) for(int u{0};u+l<=4;++u){
				ll me{f[i-1][j][k][l][u]};
				int cnt{a[i]-(l+u)},mxnews=(islower(ty)&&idx+2<=9)?cnt:0;
				for(int news{0};news<=mxnews&&j+l+u+news<=14;++news)
					for(int pr{0};pr+k<=1&&news+2*pr<=cnt&&j+l+u+news+pr*2<=14;++pr)
						for(int kz{0};news+2*pr+3*kz<=cnt&&j+l+u+news+pr*2+3*kz<=14;++kz){
							int ad{l+u+news+2*pr+3*kz};
							upd(f[i][j+ad][k||pr][news][l],me*cc[a[i]][ad]*p2[key[i]*ad]);
						}
		    }
	} upd(ans,f[34][14][1][0][0]);
}
void solve2(){
	static long long f[V][8];
	memset(f,0,sizeof f),f[0][0]=1;
	for(int i{1};i<=34;++i){
		char ty;int idx; getcard(i,ty,idx);
		for(int j{0};j<=7&&j<=2*(i-1);++j)
			for(int k{0};k<=1&&j+k<=7&&2*k<=a[i];++k)
                upd(f[i][j+k],f[i-1][j]*cc[a[i]][2*k]*p2[key[i]*2*k]);
	} upd(ans,f[34][7]*7ll);
}
void solve3(){
	const vector<int> req={1,9,10,18,19,27,28,29,30,31,32,33,34};
	for(int i:req) if(!a[i]) return ;
	long long mx{0ll};
	for(int i:req){
		if(a[i]<2) continue;
		long long s{1ll};
		for(int j:req)
			if(j==i) s*=cc[a[j]][2]*p2[key[j]*2];
			else s*=cc[a[j]][1]*p2[key[j]];
		upd(mx,s);
	} upd(ans,mx*13ll);
}
void solve(){
	fill(a+1,a+34+1,4),fill(key+1,key+34+1,false);
	string t;
	while(1){cin>>t;if(t=="0")break;--a[getid(t)];}
	while(1){cin>>t;if(t=="0")break;key[getid(t)]=true;}
	ans=0LL,solve1(),solve2(),solve3(),printf("%lld\n",ans);
}
int main(){
	cin.tie(0)->sync_with_stdio(0);
	int tc;cin>>tc;
	while(tc--)solve();
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 10
Accepted
time: 2ms
memory: 4264kb

input:

10
9s 6s N F 1s 3p E 8m S W B 8s 4m 4p F W 5m 4s 4p 2p 3m 6p 6s 8p 3p 6s 6p E 8p 2m 4s 2m Z B 7p 4s 1s N 3m 9s 5s N 3p 0
9p 2s B 7m Z N 3m 5s 4p 8m 6s S 5p 6p 9s 0
7m 4p 2s 7s 6p 8s 7p 5s 9s 9s 1p 5m 9m 5s 4p 5s E 1p 6s 5p B 4m 6m W 6p 6s E 9s 5p 2s 8s 8p 4m 3s 9m 5p 3s 2s 6s 8s 8p 6p 5m 4s 3m 4s 5s...

output:

4013162496
127401984
19874709504
47775744
573308928
15676416
2293235712
57982058496
8026324992
250822656

result:

ok 10 lines

Test #2:

score: 10
Accepted
time: 9ms
memory: 4044kb

input:

100
6s 5p 7m 3p 7p 3s 6m 5s 5m 7m 3m 4p 5p 7p 6m 5m 4p 6p 2p 6p 6s 4p 7s 4s 7p 3m 5s 1m 1p 7s 4p 5p F 5s 3s 3m 5s 6m 3p 6s 7m 2s 7m 3s 3p 3p 4m 6m 4m 7s 9m 7p S 9s 4s 8s B 5m Z 6s 9p 6p 4m 6p 4m 7s 2m 5p 3m 4s 3s 5m 8p 4s 0
6p 5m 4s 3m N 9p 7s 2m 1s 4m E 6s 5s 7m 0
7m 5m S Z 5m 3m 7p 6p 3p 3s 8p 6s ...

output:

3144241152
6624903168
31352832
2612736
317995352064
3312451584
17252352
15676416
100615716864
174680064
501645312
167215104
134154289152
1656225792
15676416
62705664
13249806336
4013162496
828112896
18579456
465813504
9704448
1916928
244944
4192321536
2208301056
6469632
20901888
2484338688
8626176
7...

result:

ok 100 lines

Test #3:

score: 10
Accepted
time: 39ms
memory: 4044kb

input:

500
3s 6s 2s 4p 7p 2p 3m 9p N 8p 1m 2m S 1s 5p 6s 5s 8m 9m 5m 6m 4m N 4p 5s 2m 3s 1p N 1m 5s 6p Z 4m Z 6s 4m 1p B 1p 8p 5p F 7m 7s 2p E E 4s 2s 6p S 8m 8s 2m S 3m 5m 2p 6m 1s 2s S W 1p 3m 4p 2p 7s 9m B 4s N B 9p 5s 7p 3s 4s 6p 3p 5p 2s Z 9s 3p 7s 1m W 6m F 4m 9s 8s 4p 3m 6m 8m 6p 9m 7m 4s 6s 3p 8m 0...

output:

7
7168
512
4096
4096
1792
28
32768
0
114688
112
524288
7
16384
128
1792
114688
448
112
32768
7168
8
1024
262144
28
131072
0
7168
1024
28
262144
1024
2048
128
1792
0
8
28
1792
65536
65536
28
512
1024
7
4096
114688
4096
16384
128
7168
114688
16384
112
65536
7
262144
2048
128
32768
28
28
28672
448
512
...

result:

ok 500 lines

Test #4:

score: 10
Accepted
time: 46ms
memory: 4036kb

input:

500
5p 4s 3m 5m 2p 3p 3s 2p W F 7m 6s E N 8p 9m 4s 6m B 9m 9s 7p 1m N 9s 7p 4p 5s 3p 5p E 8p 2m 4m F 2s 9p 1s 6p 4p F 4m 8m 5p 6m 8s 2s 6s 5m 9m W W 5s 2p 2s 6p 4p B S 7p 9s 4m B 7p 6m 9m 8s B F 7s 8s 6p Z 7s Z E 1s 6s 5p 7s 1s 9p 1m 9s 8p 4p 6m N 3p 1p 3p 2m N 2s 8m 6p 4m 7s 6s 1m 1s 0
6m B 4p 7s 8...

output:

580608
3096576
1701
2985984
193536
83607552
979776
250822656
27869184
1032192
27869184
1741824
36288
47775744
250822656
435456
382205952
27869184
27869184
5225472
15309
23887872
81648
9289728
3096576
47775744
30233088
55296
27869184
1259712
497664
1306368
6967296
9289728
27216
774144
2239488
2268
41...

result:

ok 500 lines

Test #5:

score: 10
Accepted
time: 61ms
memory: 3992kb

input:

500
7p B 6p 8m 3m 5p 5m Z 8s 4m 4p 1s 3p 6s 7s F 2p 1m 3s 9p 0
0
1p 4p 8s 2s 3p 5p 3p 9p 8s 9m 7p 6p 4p F S 7s 7s N 9p 4s 1p N E 4s 7m B 1m E 7p S 5p 0
0
2p S 8p F 5s 7p 8m 5m 5m 9s 8s E 7p 9p 1p 9p 3s 4s 8p 7s 5p 6m 8m 4s 6m 3m 9m 7m E 3s 9s 8p 1s 1p 1s 2m Z 9s 8m 9p B 9m 5p 9m S 3p 1m 4s 8s 3s 7s ...

output:

232906752
31850496
2985984
979776
310542336
19408896
3981312
1959552
232906752
29113344
5971968
1959552
131010048
17915904
1959552
244944
174680064
65505024
10077696
979776
174680064
12939264
14155776
489888
98257536
25878528
1990656
104976
232906752
25878528
11501568
1959552
98257536
34504704
48988...

result:

ok 500 lines

Test #6:

score: 10
Accepted
time: 124ms
memory: 3980kb

input:

1000
6s 5p 5s Z 1s S 9s 6p 1m 2p 7p 8m 4m 7m 0
0
9p B 4s 4p 5m N 1p 8m 4m 1m 6s W 5s N 5m 9m 3m 9s 1s 7m 5p 9m 8s 3m S 3s 1p 1m W 5s 2s 4s 9p 6m 6s 0
0
1p 9s 2s 4p 7s 1s F 8m 6p 3p 3s W 7p 4s Z E 4p 4s 6s N 8s 2m 8s 6m Z 8m 2s 8m 2p Z 2p F W 6s 9m 9s 3m 9m 1m 1m E B 7m 6s 4s 4p 2s 2m E N N 2m F 8s 4...

output:

310542336
17915904
2519424
1959552
232906752
155271168
1119744
10616832
131010048
15925248
1959552
1959552
552075264
34504704
3981312
1959552
414056448
92012544
5971968
489888
174680064
28311552
7962624
979776
174680064
69009408
23887872
3538944
310542336
122683392
15925248
1959552
310542336
1164533...

result:

ok 1000 lines

Test #7:

score: 10
Accepted
time: 147ms
memory: 4056kb

input:

1000
5p 1s 8m 6p F 8s 7m 9m 7s E 6m S 4s 9p 5m 2s 6s B 9s 2p 3s N W 3m 1p 0
Z 4s 1s 7s 9s 7p 2s 5p W 9m 3m 0
6m 5p Z 9m 7p E 3s 6p 8s 1p 9s W 9p 5s 5m 2m 7s 2p 6s N 0
2p 5p 3m 1m 1p 4m 4s 8p B 4p 2s 7p 7m 0
1m F 7p S 9p 4m E 8s 2m 6m 6s B Z W 0
2m 4m 2s 2p 7m F 1p 9m 1s 5p W 0
8s 1s 2p 3m Z 5m F 7s ...

output:

3869835264
32105299968
57982058496
347892350976
29812064256
1863254016
97844723712
65229815808
105998450688
1308622848
20639121408
3726508032
1863254016
260919263232
524040192
32105299968
2794881024
174680064
414056448
5234491392
393030144
195689447424
59624128512
97844723712
301989888
48922361856
1...

result:

ok 1000 lines

Test #8:

score: 10
Accepted
time: 222ms
memory: 4064kb

input:

1500
3m 6p 1s 8s 7s 1p W 2m S Z 2s 3s B 7m 9s F 5p 9m 1m 6s 2p 0
9s N 4s B 1m 8m 6s S 1s Z 3m 0
W 5p 3m 1s 7s E 7m 3s 6p 9m 0
S 4m 6s W 6m 2m 0
8m E 3m 1m 9m 4p 7p 6p N 5m 4s 2s W 1p 7s 3p S 5p 2p 4m 1s 0
B W N 1s E 7s 9s 6m 2s S 5p 4s F 7m 8s 1m 7p 1p 2m 0
5s 4m 6p E 2p 6m 8p B S Z 7p F 1p 0
3m E 2...

output:

18865446912
4831838208
268308578304
173946175488
9172942848
32105299968
32105299968
2717908992
18345885696
670014898176
1048080384
119248257024
158997676032
6879707136
32614907904
173946175488
309237645312
48922361856
9172942848
32105299968
19874709504
310542336
32105299968
4192321536
1719926784
489...

result:

ok 1500 lines

Test #9:

score: 10
Accepted
time: 250ms
memory: 3988kb

input:

2000
7s 4s 6s 6m F 3s Z 1p 9m 5s 3p 8p E 2p 8s 1m 8m 0
2s 3p 2p 5p 0
S 3p 4m 2s 3m 6m 5p 1s 5p 9m 4m 9s 8s 8m 5m E 1p 6m B 5s 9p 8p B 1m 9p 3m 7m 8s F 3p 8m E S 2m 6s 3s 9s 0
3m 1p F 7p 4m 1m 5p 7m 4p 6m 9p B 8p 0
4s 5m W 1m S 6s 4p 6m 9p 5m 5p 7m F W N E 4p 4s 8s 3m 3s N 3m 6m 6p B 8s F 9s 3s 4m 1p...

output:

1358954496
1528823808
603979776
501645312
52999225344
1863254016
250822656
250822656
391378894848
4076863488
1934917632
125411328
48922361856
6115295232
32105299968
1959552
12230590464
6115295232
12230590464
1003290624
141331267584
3439853568
4013162496
7838208
429981696
56623104
4013162496
50164531...

result:

ok 2000 lines

Test #10:

score: 10
Accepted
time: 312ms
memory: 4044kb

input:

2500
1m 3m 4s N 8s 9m 3p 5s 6s E 5p 2p 8p 4m B 7s 3s 9s 0
8m 0
6m N 6s 1s 7s 3m 5s 5s 8m 2p S 3s 1m 1s 6s 7p W 5m Z 5p 6p 8p Z 7p N 7s 9p 2p 5p 6p 8p 8s 9m 1m 9m 1p 0
9s 6m 4m 9p S 8s 7p 5s 8p F 2s 1p 2p B 1s Z 0
8p 2m 2p 2m 1p 5m 9s 6s W 3s 6s 4m 9p 3m 9p 7s 6s 1m 8s 8m 5s E 7m 5m 4s 8m 7p 4p 1p E ...

output:

232906752
8026324992
9937354752
15676416
8153726976
214990848
509607936
10450944
173946175488
8026324992
2579890176
32105299968
141331267584
2484338688
250822656
28311552
3439853568
38817792
21233664
339738624
679477248
16052649984
69009408
501645312
8384643072
2038431744
764411904
244944
5798205849...

result:

ok 2500 lines