Submission #205307

# Submission time Handle Problem Language Result Execution time Memory
205307 2020-02-28T13:41:36 Z TadijaSebez Bowling (BOI15_bow) C++11
82 / 100
1000 ms 1016 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int N=11;
const int M=305;
int score[N];
ll dp[M][N][N],tmp[M][N][N];
void Clear(){
	for(int i=0;i<M;i++)
		for(int j=0;j<N;j++)
			for(int k=0;k<N;k++)
				tmp[i][j][k]=dp[i][j][k],dp[i][j][k]=0;
}
void Print(int n){
	for(int i=0;i<M;i++)
		for(int j=0;j<N;j++)
			for(int k=0;k<N;k++)
				if(dp[i][j][k])
					printf("%i %i %i %i %lld\n",n,i,j,k,dp[i][j][k]);
}
void Solve(){
	int n;
	string str;
	scanf("%i",&n);
	cin>>str;
	for(int i=1;i<=n;i++)scanf("%i",&score[i]);
	Clear();
	for(int i=0;i<M;i++)if(i==score[n] || score[n]==-1){
		string now="";now+=str[n*2-2];now+=str[n*2-1];now+=str[n*2];
		//Case 1 xxx
		if((now[0]=='?' || now[0]=='x') && (now[1]=='?' || now[1]=='x') && (now[2]=='?' || now[2]=='x')){
			if(i>=30)dp[i-30][10][10]++;
		}
		//Case 2 xxA
		if((now[0]=='?' || now[0]=='x') && (now[1]=='?' || now[1]=='x')){
			for(int A=0;A<10;A++)if(now[2]=='?' || now[2]=='0'+A){
				if(i>=20+A)dp[i-20-A][10][10]++;
			}
		}
		//Case 3 xA/
		if((now[0]=='?' || now[0]=='x') && (now[2]=='?' || now[2]=='/')){
			for(int A=0;A<10;A++)if(now[1]=='?' || now[1]=='0'+A){
				if(i>=20)dp[i-20][10][A]++;
			}
		}
		//Case 4 xAB
		if(now[0]=='?' || now[0]=='x'){
			for(int A=0;A<10;A++)if(now[1]=='?' || now[1]=='0'+A)
				for(int B=0;B<10-A;B++)if(now[2]=='?' || now[2]=='0'+B){
					if(i>=10+A+B)dp[i-10-A-B][10][A]++;
				}
		}
		//Case 5 A/x
		if((now[1]=='?' || now[1]=='/') && (now[2]=='?' || now[2]=='x')){
			for(int A=0;A<10;A++)if(now[0]=='?' || now[0]=='0'+A){
				if(i>=20)dp[i-20][A][10-A]++;
			}
		}
		//Case 6 A/B
		if(now[1]=='?' || now[1]=='/'){
			for(int A=0;A<10;A++)if(now[0]=='?' || now[0]=='0'+A)
				for(int B=0;B<10;B++)if(now[2]=='?' || now[2]=='0'+B){
					if(i>=10+B)dp[i-10-B][A][10-A]++;
				}
		}
		//Case 7 AB-
		if(now[2]=='-' || now[2]=='?'){
			for(int A=0;A<10;A++)if(now[0]=='?' || now[0]=='0'+A)
				for(int B=0;B<10-A;B++)if(now[1]=='?' || now[1]=='0'+B){
					if(i>=A+B)dp[i-A-B][A][B]++;
				}
		}
	}
	//Print(n);
	for(int j=n-1;j>=1;j--){
		Clear();
		string now="";now+=str[j*2-2];now+=str[j*2-1];
		for(int i=0;i<M;i++)if(score[j]==i || score[j]==-1){
			for(int F=0;F<N;F++)for(int S=0;S<N;S++){
				//Case 1 x-
				if((now[0]=='?' || now[0]=='x') && (now[1]=='?' || now[1]=='-')){
					if(i>=10+F+S)dp[i-10-F-S][10][F]+=tmp[i][F][S];
				}
				//Case 2 A/
				if(now[1]=='?' || now[1]=='/'){
					for(int A=0;A<10;A++)if(now[0]=='?' || now[0]=='0'+A){
						if(i>=10+F)dp[i-10-F][A][10-A]+=tmp[i][F][S];
					}
				}
				//Case 3 AB
				for(int A=0;A<10;A++)if(now[0]=='?' || now[0]=='0'+A)
					for(int B=0;B<10-A;B++)if(now[1]=='?' || now[1]=='0'+B){
						if(i>=A+B)dp[i-A-B][A][B]+=tmp[i][F][S];
					}
			}
		}
		//Print(j);
	}
	ll ans=0;
	for(int F=0;F<N;F++)for(int S=0;S<N;S++)ans+=dp[0][F][S];
	printf("%lld\n",ans);
}
int main(){
	int t;scanf("%i",&t);
	while(t--)Solve();
	return 0;
}

Compilation message

bow.cpp: In function 'void Solve()':
bow.cpp:24:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  scanf("%i",&n);
  ~~~~~^~~~~~~~~
bow.cpp:26:28: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  for(int i=1;i<=n;i++)scanf("%i",&score[i]);
                       ~~~~~^~~~~~~~~~~~~~~~
bow.cpp: In function 'int main()':
bow.cpp:104:13: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
  int t;scanf("%i",&t);
        ~~~~~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 158 ms 888 KB Output is correct
2 Correct 113 ms 888 KB Output is correct
3 Correct 11 ms 888 KB Output is correct
4 Correct 11 ms 888 KB Output is correct
5 Correct 12 ms 888 KB Output is correct
6 Correct 12 ms 888 KB Output is correct
7 Correct 283 ms 888 KB Output is correct
8 Correct 254 ms 888 KB Output is correct
9 Correct 224 ms 888 KB Output is correct
10 Correct 251 ms 888 KB Output is correct
11 Correct 269 ms 888 KB Output is correct
12 Correct 142 ms 888 KB Output is correct
13 Correct 33 ms 888 KB Output is correct
14 Correct 149 ms 888 KB Output is correct
15 Correct 38 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 273 ms 888 KB Output is correct
2 Correct 263 ms 888 KB Output is correct
3 Correct 212 ms 888 KB Output is correct
4 Correct 195 ms 888 KB Output is correct
5 Correct 251 ms 888 KB Output is correct
6 Correct 291 ms 888 KB Output is correct
7 Correct 316 ms 888 KB Output is correct
8 Correct 328 ms 888 KB Output is correct
9 Correct 277 ms 888 KB Output is correct
10 Correct 599 ms 888 KB Output is correct
11 Correct 617 ms 888 KB Output is correct
12 Correct 555 ms 888 KB Output is correct
13 Correct 597 ms 1016 KB Output is correct
14 Correct 293 ms 888 KB Output is correct
15 Correct 309 ms 888 KB Output is correct
16 Correct 291 ms 888 KB Output is correct
17 Correct 311 ms 888 KB Output is correct
18 Correct 733 ms 888 KB Output is correct
19 Correct 699 ms 888 KB Output is correct
20 Correct 779 ms 888 KB Output is correct
21 Correct 738 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 157 ms 888 KB Output is correct
2 Correct 75 ms 888 KB Output is correct
3 Correct 61 ms 888 KB Output is correct
4 Correct 70 ms 888 KB Output is correct
5 Correct 103 ms 888 KB Output is correct
6 Correct 106 ms 892 KB Output is correct
7 Correct 92 ms 888 KB Output is correct
8 Correct 112 ms 888 KB Output is correct
9 Correct 84 ms 888 KB Output is correct
10 Correct 99 ms 888 KB Output is correct
11 Correct 55 ms 888 KB Output is correct
12 Correct 60 ms 888 KB Output is correct
13 Correct 65 ms 888 KB Output is correct
14 Correct 133 ms 888 KB Output is correct
15 Correct 161 ms 888 KB Output is correct
16 Correct 156 ms 940 KB Output is correct
17 Correct 176 ms 888 KB Output is correct
18 Correct 116 ms 888 KB Output is correct
19 Correct 137 ms 888 KB Output is correct
20 Correct 148 ms 888 KB Output is correct
21 Correct 158 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 346 ms 888 KB Output is correct
2 Correct 307 ms 888 KB Output is correct
3 Correct 367 ms 888 KB Output is correct
4 Correct 298 ms 888 KB Output is correct
5 Correct 284 ms 888 KB Output is correct
6 Correct 230 ms 888 KB Output is correct
7 Correct 251 ms 888 KB Output is correct
8 Correct 271 ms 888 KB Output is correct
9 Correct 265 ms 888 KB Output is correct
10 Correct 679 ms 1016 KB Output is correct
11 Correct 620 ms 888 KB Output is correct
12 Correct 611 ms 888 KB Output is correct
13 Correct 577 ms 888 KB Output is correct
14 Correct 434 ms 888 KB Output is correct
15 Correct 417 ms 888 KB Output is correct
16 Correct 399 ms 1016 KB Output is correct
17 Correct 426 ms 888 KB Output is correct
18 Correct 260 ms 888 KB Output is correct
19 Correct 232 ms 888 KB Output is correct
20 Correct 255 ms 888 KB Output is correct
21 Correct 239 ms 888 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 158 ms 888 KB Output is correct
2 Correct 113 ms 888 KB Output is correct
3 Correct 11 ms 888 KB Output is correct
4 Correct 11 ms 888 KB Output is correct
5 Correct 12 ms 888 KB Output is correct
6 Correct 12 ms 888 KB Output is correct
7 Correct 283 ms 888 KB Output is correct
8 Correct 254 ms 888 KB Output is correct
9 Correct 224 ms 888 KB Output is correct
10 Correct 251 ms 888 KB Output is correct
11 Correct 269 ms 888 KB Output is correct
12 Correct 142 ms 888 KB Output is correct
13 Correct 33 ms 888 KB Output is correct
14 Correct 149 ms 888 KB Output is correct
15 Correct 38 ms 888 KB Output is correct
16 Correct 273 ms 888 KB Output is correct
17 Correct 263 ms 888 KB Output is correct
18 Correct 212 ms 888 KB Output is correct
19 Correct 195 ms 888 KB Output is correct
20 Correct 251 ms 888 KB Output is correct
21 Correct 291 ms 888 KB Output is correct
22 Correct 316 ms 888 KB Output is correct
23 Correct 328 ms 888 KB Output is correct
24 Correct 277 ms 888 KB Output is correct
25 Correct 599 ms 888 KB Output is correct
26 Correct 617 ms 888 KB Output is correct
27 Correct 555 ms 888 KB Output is correct
28 Correct 597 ms 1016 KB Output is correct
29 Correct 293 ms 888 KB Output is correct
30 Correct 309 ms 888 KB Output is correct
31 Correct 291 ms 888 KB Output is correct
32 Correct 311 ms 888 KB Output is correct
33 Correct 733 ms 888 KB Output is correct
34 Correct 699 ms 888 KB Output is correct
35 Correct 779 ms 888 KB Output is correct
36 Correct 738 ms 888 KB Output is correct
37 Correct 157 ms 888 KB Output is correct
38 Correct 75 ms 888 KB Output is correct
39 Correct 61 ms 888 KB Output is correct
40 Correct 70 ms 888 KB Output is correct
41 Correct 103 ms 888 KB Output is correct
42 Correct 106 ms 892 KB Output is correct
43 Correct 92 ms 888 KB Output is correct
44 Correct 112 ms 888 KB Output is correct
45 Correct 84 ms 888 KB Output is correct
46 Correct 99 ms 888 KB Output is correct
47 Correct 55 ms 888 KB Output is correct
48 Correct 60 ms 888 KB Output is correct
49 Correct 65 ms 888 KB Output is correct
50 Correct 133 ms 888 KB Output is correct
51 Correct 161 ms 888 KB Output is correct
52 Correct 156 ms 940 KB Output is correct
53 Correct 176 ms 888 KB Output is correct
54 Correct 116 ms 888 KB Output is correct
55 Correct 137 ms 888 KB Output is correct
56 Correct 148 ms 888 KB Output is correct
57 Correct 158 ms 888 KB Output is correct
58 Correct 346 ms 888 KB Output is correct
59 Correct 307 ms 888 KB Output is correct
60 Correct 367 ms 888 KB Output is correct
61 Correct 298 ms 888 KB Output is correct
62 Correct 284 ms 888 KB Output is correct
63 Correct 230 ms 888 KB Output is correct
64 Correct 251 ms 888 KB Output is correct
65 Correct 271 ms 888 KB Output is correct
66 Correct 265 ms 888 KB Output is correct
67 Correct 679 ms 1016 KB Output is correct
68 Correct 620 ms 888 KB Output is correct
69 Correct 611 ms 888 KB Output is correct
70 Correct 577 ms 888 KB Output is correct
71 Correct 434 ms 888 KB Output is correct
72 Correct 417 ms 888 KB Output is correct
73 Correct 399 ms 1016 KB Output is correct
74 Correct 426 ms 888 KB Output is correct
75 Correct 260 ms 888 KB Output is correct
76 Correct 232 ms 888 KB Output is correct
77 Correct 255 ms 888 KB Output is correct
78 Correct 239 ms 888 KB Output is correct
79 Correct 302 ms 888 KB Output is correct
80 Correct 306 ms 888 KB Output is correct
81 Correct 235 ms 888 KB Output is correct
82 Correct 230 ms 888 KB Output is correct
83 Correct 201 ms 888 KB Output is correct
84 Correct 76 ms 888 KB Output is correct
85 Correct 103 ms 888 KB Output is correct
86 Correct 73 ms 888 KB Output is correct
87 Correct 92 ms 888 KB Output is correct
88 Correct 463 ms 888 KB Output is correct
89 Correct 585 ms 888 KB Output is correct
90 Correct 563 ms 888 KB Output is correct
91 Correct 556 ms 888 KB Output is correct
92 Correct 312 ms 888 KB Output is correct
93 Execution timed out 1085 ms 888 KB Time limit exceeded
94 Halted 0 ms 0 KB -