답안 #205306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
205306 2020-02-28T13:39:26 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;B++)if(A+B<10 && (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;B++)if(A+B<10 && (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;B++)if(A+B<10 && (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);
        ~~~~~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 204 ms 888 KB Output is correct
2 Correct 131 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 13 ms 888 KB Output is correct
7 Correct 328 ms 888 KB Output is correct
8 Correct 312 ms 888 KB Output is correct
9 Correct 303 ms 888 KB Output is correct
10 Correct 328 ms 1016 KB Output is correct
11 Correct 359 ms 888 KB Output is correct
12 Correct 172 ms 888 KB Output is correct
13 Correct 38 ms 888 KB Output is correct
14 Correct 168 ms 888 KB Output is correct
15 Correct 43 ms 892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 366 ms 888 KB Output is correct
2 Correct 318 ms 888 KB Output is correct
3 Correct 267 ms 892 KB Output is correct
4 Correct 250 ms 1016 KB Output is correct
5 Correct 304 ms 888 KB Output is correct
6 Correct 378 ms 888 KB Output is correct
7 Correct 413 ms 888 KB Output is correct
8 Correct 406 ms 888 KB Output is correct
9 Correct 354 ms 888 KB Output is correct
10 Correct 746 ms 888 KB Output is correct
11 Correct 760 ms 888 KB Output is correct
12 Correct 717 ms 888 KB Output is correct
13 Correct 730 ms 892 KB Output is correct
14 Correct 364 ms 888 KB Output is correct
15 Correct 373 ms 888 KB Output is correct
16 Correct 345 ms 888 KB Output is correct
17 Correct 378 ms 888 KB Output is correct
18 Correct 979 ms 888 KB Output is correct
19 Correct 908 ms 888 KB Output is correct
20 Correct 980 ms 888 KB Output is correct
21 Correct 927 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 217 ms 888 KB Output is correct
2 Correct 78 ms 888 KB Output is correct
3 Correct 79 ms 888 KB Output is correct
4 Correct 92 ms 888 KB Output is correct
5 Correct 143 ms 888 KB Output is correct
6 Correct 149 ms 936 KB Output is correct
7 Correct 125 ms 888 KB Output is correct
8 Correct 161 ms 888 KB Output is correct
9 Correct 106 ms 888 KB Output is correct
10 Correct 113 ms 888 KB Output is correct
11 Correct 66 ms 888 KB Output is correct
12 Correct 69 ms 888 KB Output is correct
13 Correct 79 ms 888 KB Output is correct
14 Correct 162 ms 888 KB Output is correct
15 Correct 193 ms 892 KB Output is correct
16 Correct 187 ms 888 KB Output is correct
17 Correct 210 ms 888 KB Output is correct
18 Correct 147 ms 888 KB Output is correct
19 Correct 179 ms 888 KB Output is correct
20 Correct 190 ms 888 KB Output is correct
21 Correct 200 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 444 ms 888 KB Output is correct
2 Correct 375 ms 888 KB Output is correct
3 Correct 449 ms 888 KB Output is correct
4 Correct 374 ms 888 KB Output is correct
5 Correct 346 ms 888 KB Output is correct
6 Correct 286 ms 888 KB Output is correct
7 Correct 300 ms 888 KB Output is correct
8 Correct 295 ms 888 KB Output is correct
9 Correct 319 ms 888 KB Output is correct
10 Correct 814 ms 888 KB Output is correct
11 Correct 734 ms 888 KB Output is correct
12 Correct 704 ms 888 KB Output is correct
13 Correct 679 ms 888 KB Output is correct
14 Correct 560 ms 888 KB Output is correct
15 Correct 584 ms 888 KB Output is correct
16 Correct 500 ms 888 KB Output is correct
17 Correct 570 ms 888 KB Output is correct
18 Correct 335 ms 888 KB Output is correct
19 Correct 292 ms 888 KB Output is correct
20 Correct 317 ms 884 KB Output is correct
21 Correct 320 ms 888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 204 ms 888 KB Output is correct
2 Correct 131 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 13 ms 888 KB Output is correct
7 Correct 328 ms 888 KB Output is correct
8 Correct 312 ms 888 KB Output is correct
9 Correct 303 ms 888 KB Output is correct
10 Correct 328 ms 1016 KB Output is correct
11 Correct 359 ms 888 KB Output is correct
12 Correct 172 ms 888 KB Output is correct
13 Correct 38 ms 888 KB Output is correct
14 Correct 168 ms 888 KB Output is correct
15 Correct 43 ms 892 KB Output is correct
16 Correct 366 ms 888 KB Output is correct
17 Correct 318 ms 888 KB Output is correct
18 Correct 267 ms 892 KB Output is correct
19 Correct 250 ms 1016 KB Output is correct
20 Correct 304 ms 888 KB Output is correct
21 Correct 378 ms 888 KB Output is correct
22 Correct 413 ms 888 KB Output is correct
23 Correct 406 ms 888 KB Output is correct
24 Correct 354 ms 888 KB Output is correct
25 Correct 746 ms 888 KB Output is correct
26 Correct 760 ms 888 KB Output is correct
27 Correct 717 ms 888 KB Output is correct
28 Correct 730 ms 892 KB Output is correct
29 Correct 364 ms 888 KB Output is correct
30 Correct 373 ms 888 KB Output is correct
31 Correct 345 ms 888 KB Output is correct
32 Correct 378 ms 888 KB Output is correct
33 Correct 979 ms 888 KB Output is correct
34 Correct 908 ms 888 KB Output is correct
35 Correct 980 ms 888 KB Output is correct
36 Correct 927 ms 888 KB Output is correct
37 Correct 217 ms 888 KB Output is correct
38 Correct 78 ms 888 KB Output is correct
39 Correct 79 ms 888 KB Output is correct
40 Correct 92 ms 888 KB Output is correct
41 Correct 143 ms 888 KB Output is correct
42 Correct 149 ms 936 KB Output is correct
43 Correct 125 ms 888 KB Output is correct
44 Correct 161 ms 888 KB Output is correct
45 Correct 106 ms 888 KB Output is correct
46 Correct 113 ms 888 KB Output is correct
47 Correct 66 ms 888 KB Output is correct
48 Correct 69 ms 888 KB Output is correct
49 Correct 79 ms 888 KB Output is correct
50 Correct 162 ms 888 KB Output is correct
51 Correct 193 ms 892 KB Output is correct
52 Correct 187 ms 888 KB Output is correct
53 Correct 210 ms 888 KB Output is correct
54 Correct 147 ms 888 KB Output is correct
55 Correct 179 ms 888 KB Output is correct
56 Correct 190 ms 888 KB Output is correct
57 Correct 200 ms 888 KB Output is correct
58 Correct 444 ms 888 KB Output is correct
59 Correct 375 ms 888 KB Output is correct
60 Correct 449 ms 888 KB Output is correct
61 Correct 374 ms 888 KB Output is correct
62 Correct 346 ms 888 KB Output is correct
63 Correct 286 ms 888 KB Output is correct
64 Correct 300 ms 888 KB Output is correct
65 Correct 295 ms 888 KB Output is correct
66 Correct 319 ms 888 KB Output is correct
67 Correct 814 ms 888 KB Output is correct
68 Correct 734 ms 888 KB Output is correct
69 Correct 704 ms 888 KB Output is correct
70 Correct 679 ms 888 KB Output is correct
71 Correct 560 ms 888 KB Output is correct
72 Correct 584 ms 888 KB Output is correct
73 Correct 500 ms 888 KB Output is correct
74 Correct 570 ms 888 KB Output is correct
75 Correct 335 ms 888 KB Output is correct
76 Correct 292 ms 888 KB Output is correct
77 Correct 317 ms 884 KB Output is correct
78 Correct 320 ms 888 KB Output is correct
79 Correct 387 ms 888 KB Output is correct
80 Correct 365 ms 888 KB Output is correct
81 Correct 291 ms 888 KB Output is correct
82 Correct 295 ms 888 KB Output is correct
83 Correct 264 ms 888 KB Output is correct
84 Correct 89 ms 888 KB Output is correct
85 Correct 132 ms 888 KB Output is correct
86 Correct 92 ms 888 KB Output is correct
87 Correct 104 ms 888 KB Output is correct
88 Correct 568 ms 888 KB Output is correct
89 Correct 717 ms 888 KB Output is correct
90 Correct 684 ms 888 KB Output is correct
91 Correct 714 ms 888 KB Output is correct
92 Correct 379 ms 892 KB Output is correct
93 Execution timed out 1090 ms 888 KB Time limit exceeded
94 Halted 0 ms 0 KB -