QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#44209#3615. Oreperations ResearchLangdao_ZhangAC ✓4137ms5924kbC++1.7kb2022-08-13 16:31:492022-08-13 16:31:51

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-08-13 16:31:51]
  • 评测
  • 测评结果:AC
  • 用时:4137ms
  • 内存:5924kb
  • [2022-08-13 16:31:49]
  • 提交

answer

#include<iostream>

#define yes "Yes\n"
#define no "No\n"

#define maxa 51
#define maxb 51
#define maxc 102
#define maxsz 2000006

using
		namespace
					std;

int na,nb,nc;
bool dp[maxa][maxb][maxc];
int a[maxa],b[maxb],c[maxc];
int sa[maxa],sb[maxb];
bool valid[maxsz];

int qsa(int l,int r){
	
	if(r==l-1||l==1&&r==na) return 0;
	if(l<=r) return sa[r]-sa[l-1];
	else return sa[na]-(sa[l-1]-sa[r]);
}

int qsb(int l,int r){
	
	if(r==l-1||l==1&&r==nb) return 0;
	if(l<=r) return sb[r]-sb[l-1];
	else return sb[nb]-(sb[l-1]-sb[r]);
}

signed main(){
	
	cin>>na>>nb>>nc;
	
	for(int i=1;i<=na;i++){
		
		cin>>a[i];
		sa[i]=sa[i-1]+a[i];
	}
	
	for(int i=1;i<=nb;i++){
		
		cin>>b[i];
		sb[i]=sb[i-1]+b[i];
	}
	
	for(int i=0;i<maxsz;i+=sa[na]){
		
		valid[i]=true;
	}
	
	for(int i=0;i<maxsz-sb[nb];i++){
		
		if(valid[i]){
			
			valid[i+sb[nb]]=true;
		}
	}
	
	for(int i=1;i<=nc;i++){
		
		cin>>c[i];
	}
	
	dp[na][nb][0]=true;
	
	for(int k=1;k<=nc;k++){
		
		for(int i=1;i<=na;i++){
			
			for(int j=1;j<=nb;j++){
				
				for(int pi=1;pi<=na;pi++){
					
					for(int pj=1;pj<=nb;pj++){
						
						int tem=c[k]-qsa(pi%na+1,i)-qsb(pj%nb+1,j);
						
						if(tem>=0&&valid[tem]){
							
							dp[i][j][k]=dp[i][j][k]||dp[pi][pj][k-1];
							
							//cout<<i<<' '<<j<<' '<<pi<<' '<<pj<<' '<<k<<' '<<dp[i][j][k]<<' '<<tem<<endl;
						}
					}
				}
			}
		}
	}
	
	bool kot=false;
	
	for(int i=1;i<=na;i++){
		
		for(int j=1;j<=nb;j++){
			
			kot=kot||dp[i][j][nc];
		}
	}
	
	cout<<(kot?yes:no);
	
end:
	return EOF+1;
}
/*
3 4 3
4 3 2
1 5 2 2
8 5 4

3 4 3
4 3 2
1 5 2 2
8 5 3
*/

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 5552kb

input:

3 4 3
4 3 2
1 5 2 2
8 5 4

output:

Yes

result:

ok answer is YES

Test #2:

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

input:

3 4 3
4 3 2
1 5 2 2
8 5 3

output:

No

result:

ok answer is NO

Test #3:

score: 0
Accepted
time: 3592ms
memory: 5760kb

input:

50 50 100
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
2000000 2000000 2000000 2000000 2000000 2000000 2000000 2000000 2000000 2000000 2000000 20...

output:

Yes

result:

ok answer is YES

Test #4:

score: 0
Accepted
time: 4137ms
memory: 5796kb

input:

50 50 100
176 117 116 9 143 58 107 88 60 60 111 77 162 177 54 79 176 66 98 199 109 19 190 42 3 175 101 20 179 161 175 112 65 86 165 117 33 49 127 91 34 182 180 71 179 83 162 10 3 84
23 41 109 175 103 49 116 127 150 105 75 116 48 181 153 75 159 183 18 162 38 88 169 159 12 32 165 2 114 171 65 119 48 5...

output:

Yes

result:

ok answer is YES

Test #5:

score: 0
Accepted
time: 4082ms
memory: 5924kb

input:

50 50 100
141 179 19 74 78 69 76 114 17 195 74 166 100 137 130 189 136 157 71 200 21 77 123 5 105 71 32 10 187 185 158 48 101 130 176 131 81 185 50 191 10 157 110 181 110 93 95 70 139 25
5 87 120 16 51 77 38 19 61 83 63 170 174 98 37 94 137 65 30 102 158 13 166 22 167 146 189 173 187 75 51 37 123 17...

output:

No

result:

ok answer is NO

Test #6:

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

input:

8 8 100
1 2 4 8 16 32 64 128
1 2 4 8 16 32 64 128
175454 885 28552 93601 157966 98437 86955 119104 139740 237633 223377 126538 79251 91376 128205 105600 153317 64467 114208 97382 160132 155546 105826 213204 69981 85036 39810 46183 88708 167884 64134 51124 124842 166249 132087 176205 145380 209718 12...

output:

No

result:

ok answer is NO

Test #7:

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

input:

8 8 100
1 2 4 8 16 32 64 128
1 2 4 8 16 32 64 128
175454 885 28552 93601 157966 98437 86955 119104 139740 237633 223377 126538 79251 91376 128205 105600 153317 64467 114208 97382 160132 155546 105826 213204 69981 85036 39810 46183 88708 167884 64134 51124 124842 166249 132087 176205 145380 209718 12...

output:

Yes

result:

ok answer is YES

Test #8:

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

input:

1 1 1
10
7
10

output:

Yes

result:

ok answer is YES

Test #9:

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

input:

1 1 1
10
7
7

output:

Yes

result:

ok answer is YES

Test #10:

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

input:

1 1 1
10
7
17

output:

Yes

result:

ok answer is YES

Test #11:

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

input:

1 1 1
10
7
49

output:

Yes

result:

ok answer is YES

Test #12:

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

input:

1 1 1
10
7
50

output:

Yes

result:

ok answer is YES

Test #13:

score: 0
Accepted
time: 5ms
memory: 5544kb

input:

1 1 1
10
7
51

output:

Yes

result:

ok answer is YES

Test #14:

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

input:

1 1 1
10
7
53

output:

No

result:

ok answer is NO

Test #15:

score: 0
Accepted
time: 2ms
memory: 5548kb

input:

2 5 77
184 169
142 18 120 63 48
3427 4803 6221 2097 1422 5392 5952 3332 5315 1734 2257 5958 945 4534 3592 2301 3741 4551 1892 3737 2258 6696 2882 4252 3063 5225 5523 3537 2007 4613 2561 3730 2858 2509 2986 5160 6855 2987 4125 3813 2145 4053 4218 3015 2824 4225 2871 3433 6236 3962 3579 2381 1366 3232...

output:

No

result:

ok answer is NO

Test #16:

score: 0
Accepted
time: 2ms
memory: 5620kb

input:

2 5 77
184 169
142 18 120 63 48
3427 4803 6221 2097 1422 5392 5952 3332 5315 1734 2257 5958 945 4534 3592 2301 3741 4551 1892 3737 2258 6696 2882 4252 3063 5225 5523 3537 2007 4613 2561 3730 2858 2509 2986 5160 6855 2987 4125 3813 2145 4053 4218 3015 2824 4225 2871 3433 6236 3962 3579 2381 1366 3232...

output:

Yes

result:

ok answer is YES

Test #17:

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

input:

18 17 68
100 40 174 66 163 54 126 116 133 63 175 164 100 157 178 39 76 45
111 70 200 137 50 146 162 75 1 147 7 93 197 31 98 111 184
10474 20108 32034 13972 26395 20063 19518 10329 24365 29103 16502 20881 29051 23916 24991 24958 9660 33360 23124 32239 12066 20307 2928 30356 11472 7599 31413 30376 284...

output:

No

result:

ok answer is NO

Test #18:

score: 0
Accepted
time: 12ms
memory: 5656kb

input:

11 20 30
12 126 96 193 79 35 138 186 189 116 35
13 192 198 114 57 166 57 9 163 37 121 174 151 173 160 113 167 110 60 159
19398 11097 27810 9747 8808 22979 11651 22326 17454 21869 14217 21623 17636 35305 26466 21782 25157 26332 14245 32132 19849 2894 28643 10547 6025 26250 27693 6529 14418 27561

output:

No

result:

ok answer is NO

Test #19:

score: 0
Accepted
time: 18ms
memory: 5556kb

input:

6 38 26
23 193 180 87 134 108
111 185 45 31 153 104 6 31 104 58 64 128 106 35 71 195 120 194 13 187 178 131 173 58 21 197 50 41 67 70 27 80 26 134 9 106 87 2
276636 1823716 46601 873803 1124444 1082582 1474787 985615 398422 727275 423970 813342 1264475 581773 680264 1836495 1987231 1798624 210811 66...

output:

Yes

result:

ok answer is YES

Test #20:

score: 0
Accepted
time: 36ms
memory: 5664kb

input:

18 17 68
100 40 174 66 163 54 126 116 133 63 175 164 100 157 178 39 76 45
111 70 200 137 50 146 162 75 1 147 7 93 197 31 98 111 184
10474 20108 32034 13972 26395 20063 19518 10329 24365 29103 16502 20881 29051 23916 24991 24958 9660 33360 23124 32239 12066 20307 2928 30356 11472 7599 31413 30376 284...

output:

Yes

result:

ok answer is YES

Test #21:

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

input:

34 43 97
55 37 152 48 114 99 90 78 188 167 38 190 167 107 158 138 79 142 59 60 93 10 77 69 10 97 45 197 66 73 119 18 131 149
58 180 22 87 74 200 45 34 56 188 30 181 7 83 7 141 66 152 138 65 5 48 3 12 154 131 104 174 125 108 144 36 9 89 127 18 68 61 129 102 112 36 4
22426 12676 17864 8494 16984 7381 ...

output:

No

result:

ok answer is NO

Test #22:

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

input:

11 20 30
12 126 96 193 79 35 138 186 189 116 35
13 192 198 114 57 166 57 9 163 37 121 174 151 173 160 113 167 110 60 159
19398 11097 27810 9747 8808 22979 11651 22326 17454 21869 14217 21623 17636 35305 26466 21782 25157 26332 14245 32132 19849 2894 28643 10547 6025 26250 27693 6529 14418 27560

output:

Yes

result:

ok answer is YES

Test #23:

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

input:

18 46 88
180 137 140 121 20 153 130 171 73 98 110 59 125 32 105 157 91 101
67 138 122 103 151 44 38 197 124 78 55 160 118 7 6 80 162 24 29 109 2 11 14 71 168 87 159 112 181 186 60 104 52 158 125 73 107 87 114 108 106 187 45 83 131 168
7945 12825 12169 21142 7955 6600 19300 11335 22130 6139 18494 484...

output:

No

result:

ok answer is NO

Test #24:

score: 0
Accepted
time: 17ms
memory: 5496kb

input:

6 38 26
23 193 180 87 134 108
111 185 45 31 153 104 6 31 104 58 64 128 106 35 71 195 120 194 13 187 178 131 173 58 21 197 50 41 67 70 27 80 26 134 9 106 87 2
276636 1823716 46601 873803 1124444 1082582 1474787 985615 398422 727275 423970 813342 1264475 581773 680264 1836495 1987231 1798624 210811 66...

output:

Yes

result:

ok answer is YES

Test #25:

score: 0
Accepted
time: 198ms
memory: 5632kb

input:

21 31 80
106 15 56 31 58 127 148 30 65 108 123 20 23 195 146 2 66 66 125 45 186
120 10 78 78 142 59 136 123 188 8 1 55 15 156 149 169 42 23 40 59 170 108 43 42 119 91 25 173 31 66 82
2758 9300 9170 11305 9722 9195 10151 6587 13098 4897 15172 14810 16649 6709 12355 10666 9289 10663 9797 2947 7387 129...

output:

Yes

result:

ok answer is YES

Test #26:

score: 0
Accepted
time: 5ms
memory: 5616kb

input:

19 3 17
110 140 154 69 144 154 114 193 186 114 24 25 77 135 47 187 78 83 1
138 15 57
683 5265 1836 8267 4571 6243 2413 7449 1220 7709 4612 4056 1813 7044 6246 4235 1163

output:

Yes

result:

ok answer is YES

Test #27:

score: 0
Accepted
time: 140ms
memory: 5612kb

input:

17 39 58
82 134 95 172 64 152 113 148 192 81 28 125 173 130 132 127 104
119 100 139 28 148 176 113 14 144 29 127 44 185 120 198 153 9 148 32 22 56 88 60 42 97 112 149 148 97 98 55 8 102 148 92 1 124 173 62
8782 5486 13474 13068 10334 10033 12114 16832 14760 2642 9645 21144 11186 18317 10131 10166 10...

output:

No

result:

ok answer is NO

Test #28:

score: 0
Accepted
time: 2ms
memory: 5560kb

input:

5 26 41
134 113 167 124 8
180 171 101 68 22 145 123 29 17 120 190 91 75 166 124 121 58 109 121 115 189 75 67 102 100 9
9144 9857 10717 4077 3660 8968 10649 4854 4292 9645 9721 6520 9769 3704 2888 7572 6781 6145 1572 5707 8779 10262 9474 5567 2524 6267 4403 8511 6334 3060 4241 7316 4904 11401 8655 22...

output:

No

result:

ok answer is NO

Test #29:

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

input:

5 31 15
62 129 12 138 112
174 21 166 70 66 194 195 188 20 116 125 106 182 52 61 40 50 68 160 53 37 79 103 162 137 115 39 90 197 62 49
8802 3449 11446 7861 10824 5453 1690 2119 1874 3189 10650 9244 11710 1294 13811

output:

Yes

result:

ok answer is YES

Test #30:

score: 0
Accepted
time: 206ms
memory: 5748kb

input:

41 42 13
15 85 38 7 80 193 128 139 155 49 196 132 67 106 18 95 133 48 102 184 97 43 42 178 46 88 139 145 90 106 113 62 122 10 83 82 54 85 155 191 137
37 61 107 24 43 86 70 193 187 138 6 102 8 150 9 186 50 72 164 163 109 156 81 8 189 120 149 189 102 122 19 149 40 16 131 192 91 89 96 85 175 114
19761 ...

output:

Yes

result:

ok answer is YES

Test #31:

score: 0
Accepted
time: 53ms
memory: 5620kb

input:

17 25 55
113 66 84 139 30 14 112 156 107 120 94 30 132 42 148 141 123
68 77 199 45 162 176 39 179 96 179 185 176 82 58 30 126 88 29 146 135 50 176 21 8 152
13639 11805 8025 12876 9046 13034 14064 6740 4745 11599 11427 1770 7457 12980 9917 12185 7435 4289 11605 12695 14200 8682 6066 8602 7324 8315 29...

output:

Yes

result:

ok answer is YES

Test #32:

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

input:

1 45 100
141
146 17 164 29 137 36 23 137 15 152 196 58 76 114 39 138 103 146 31 4 109 92 35 33 67 4 87 173 30 90 193 161 8 94 25 194 38 30 32 73 88 166 56 124 32
12371 2802 6369 14738 1527 1623 5200 11866 12145 9017 2506 5434 9923 3126 14814 4742 6903 9969 12867 7218 8213 486 6123 4837 8226 9239 890...

output:

No

result:

ok answer is NO

Test #33:

score: 0
Accepted
time: 18ms
memory: 5612kb

input:

19 10 69
78 91 175 2 161 55 47 189 12 94 91 56 198 178 39 64 69 108 197
92 7 34 109 95 46 143 60 32 84
6047 8555 2228 3985 8100 5393 7849 6442 4893 3132 5149 7414 7964 9024 4748 4728 2995 3339 8337 2382 4162 8027 3234 4727 3245 7379 4956 7431 7658 7797 5363 5204 8787 3976 2885 2666 5552 8009 1921 23...

output:

Yes

result:

ok answer is YES

Test #34:

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

input:

37 13 49
94 21 64 165 14 193 44 192 47 179 20 197 89 6 175 86 156 27 23 140 20 79 50 7 75 42 72 101 151 99 119 200 6 82 91 85 14
102 153 81 50 72 54 199 10 24 116 121 50 103
5369 9648 10897 13204 6413 12897 9689 10490 11648 13128 11445 10836 3053 5594 14730 1384 14224 7026 12651 7382 10748 4328 1609...

output:

No

result:

ok answer is NO