ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#211420 | #3804. 小璃的战斗 | drdilyor | 18 | 22ms | 4620kb | C++11 | 2.4kb | 2024-08-11 11:38:40 | 2024-08-11 13:09:52 |
answer
#include<bits/stdc++.h>
#define int long long
using namespace std;
void ts(){cout<<"IAKIOI\n";}
inline int read(){
int n=0,f=1,ch=getchar();
while(ch<'0'||ch>'9'){
if(ch=='-')f=-1;
ch=getchar();
}
while(ch>='0'&&ch<='9'){
n=n*10+ch-'0';
ch=getchar();
}
return n*f;
}
const int mod=998244353;
struct mint{
int x;mint(int o=0){x=o;}mint&operator+=(mint a){return(x+=a.x)%=mod,*this;}mint&operator-=(mint a){return(x+=mod-a.x)%=mod,*this;}
mint&operator*=(mint a){return(x=1ll*x*a.x%mod),*this;}mint&operator^=( int b){mint a=*this;x=1;while(b)(b&1)&&(*this*=a,1),a*=a,b>>=1;return*this;}
mint&operator/=(mint a){return*this*=(a^=mod-2);}friend mint operator+(mint a,mint b){return a+=b;}friend mint operator-(mint a,mint b){return a-=b;}
friend mint operator*(mint a,mint b){return a*=b;}friend mint operator/(mint a,mint b){return a/=b;}friend mint operator^(mint a,int b){return a^=b;}
mint operator-(){return 0-*this;}bool operator==(const mint b)const{return x==b.x;}
};
int n,l,e;
int c[305],p[10];
int dp[305][241][305][2];
int ne[241][305][2];
//前 i 次,目前能量 j, 发动了 k 次厉害的攻击,0/1 次不太厉害的攻击的情况数.
signed main(){
n=read();
for(int i=1;i<=n;i++)c[i]=read();
l=read();
for(int i=1;i<=l;i++)p[i]=read();
sort(p+1,p+l+1);
e=read();
dp[0][e][0][0]=1;
for(int i=1;i<=n;i++){
memcpy(dp[i],dp[i-1],sizeof(dp[i]));
for(int j=1;j<=c[i];j++){
for(int k=0;k<=240;k++)for(int x=0;x<=300;x++)for(int y=0;y<2;y++)ne[k][x][y]=0;
for(int k=1;k<=l;k++){
int v=p[k];
for(int x=0;x<=240;x++){
for(int y=0;y<=300;y++){
for(int z=0;z<2;z++){
if(!dp[i][x][y][z])continue;
(ne[min(x+v,240ll)][y][z]+=dp[i][x][y][z])%=mod;
if(x>=120&&v)(ne[min(240ll,x-115+v)][y+1][z]+=dp[i][x][y][z])%=mod;
else if(x>=120)(ne[x-115][y+(z+1)/2][(z+1)%2]+=dp[i][x][y][z])%=mod;
}
}
}
}
memcpy(dp[i],ne,sizeof(dp[i]));
}
for(int k=0;k<=240;k++)for(int x=0;x<=300;x++)for(int y=0;y<2;y++)ne[k][x][y]=0;
for(int x=0;x<=240;x++){
for(int y=0;y<=300;y++){
for(int z=0;z<2;z++){
if(!dp[i][x][y][z])continue;
(ne[min(x+20,240ll)][y][z]+=dp[i][x][y][z])%=mod;
}
}
}
memcpy(dp[i],ne,sizeof(dp[i]));
}
int res=0;
for(int i=0;i<=240;i++){
for(int j=0;j<=300;j++){
for(int k=0;k<2;k++)res+=j*dp[n][i][j][k]%mod,res%=mod;
}
}
printf("%lld\n",res);
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 2
Accepted
time: 0ms
memory: 4616kb
input:
2 2 4 1 25 167
output:
34
result:
ok "34"
Test #2:
score: 2
Accepted
time: 4ms
memory: 3468kb
input:
1 4 2 40 45 223
output:
304
result:
ok "304"
Test #3:
score: 2
Accepted
time: 5ms
memory: 4620kb
input:
2 2 4 2 0 45 161
output:
1159
result:
ok "1159"
Test #4:
score: 2
Accepted
time: 0ms
memory: 4616kb
input:
2 2 1 2 25 35 221
output:
72
result:
ok "72"
Test #5:
score: 2
Accepted
time: 0ms
memory: 3468kb
input:
1 1 1 40 6
output:
0
result:
ok "0"
Test #6:
score: 2
Accepted
time: 0ms
memory: 3484kb
input:
1 4 2 30 25 55
output:
16
result:
ok "16"
Test #7:
score: 2
Accepted
time: 5ms
memory: 4616kb
input:
2 1 4 1 45 161
output:
35
result:
ok "35"
Test #8:
score: 2
Accepted
time: 4ms
memory: 3468kb
input:
1 4 2 0 25 55
output:
1
result:
ok "1"
Test #9:
score: 2
Accepted
time: 4ms
memory: 4620kb
input:
2 2 3 1 0 33
output:
0
result:
ok "0"
Test #10:
score: 0
Time Limit Exceeded
input:
277 605376561 910253890 270922374 265125322 736886507 204360393 143001007 642923206 784883218 695993...
output:
result:
Test #11:
score: 0
Time Limit Exceeded
input:
170 202076194 345630086 998085568 788765708 814906822 849504079 803465657 206348014 611944107 968416...
output:
result:
Test #12:
score: 0
Time Limit Exceeded
input:
206 551757632 422666542 368785100 39513480 360101767 609597999 532143607 897007896 191082378 9597631...
output:
result:
Test #13:
score: 0
Time Limit Exceeded
input:
150 835438994 389440405 775872291 825712716 312687066 137989104 902156563 321463095 644646631 435007...
output:
result:
Test #14:
score: 0
Time Limit Exceeded
input:
225 531574213 910194584 655048830 143130111 76538835 123155107 311114315 691976412 266555772 5221147...
output:
result:
Test #15:
score: 0
Time Limit Exceeded
input:
241 186651760 198152450 726519229 975856337 536323475 199914159 302294459 28093616 31811668 94929609...
output:
result:
Test #16:
score: 0
Time Limit Exceeded
input:
145 825382719 303695251 160033591 558973047 901737205 584232659 221381948 464760435 741550741 207899...
output:
result:
Test #17:
score: 0
Time Limit Exceeded
input:
236 210 269 265 217 151 268 237 246 244 176 214 168 199 161 263 150 171 152 220 298 240 281 177 180 ...
output:
result:
Test #18:
score: 0
Time Limit Exceeded
input:
204 285 295 187 215 197 200 166 231 291 189 220 193 257 182 176 166 174 258 257 250 286 163 277 251 ...
output:
result:
Test #19:
score: 0
Time Limit Exceeded
input:
279 207 286 174 168 254 272 290 164 250 268 232 212 209 211 207 172 216 279 247 272 161 152 288 159 ...
output:
result:
Test #20:
score: 0
Time Limit Exceeded
input:
232 203 245 215 277 284 227 165 270 167 162 251 197 171 171 218 218 177 286 161 277 208 156 232 256 ...
output:
result:
Test #21:
score: 0
Time Limit Exceeded
input:
246 177 227 271 229 211 242 291 299 245 280 206 276 212 248 271 184 153 228 193 288 261 284 191 248 ...
output:
result:
Test #22:
score: 0
Time Limit Exceeded
input:
218 186 214 206 222 213 270 183 192 206 187 206 262 200 184 182 209 167 240 275 221 174 278 281 235 ...
output:
result:
Test #23:
score: 0
Time Limit Exceeded
input:
203 256 175 253 274 241 254 268 219 264 161 163 274 249 278 215 245 212 295 173 269 222 213 222 236 ...
output:
result:
Test #24:
score: 0
Time Limit Exceeded
input:
297 183 180 260 223 240 273 193 222 207 237 226 286 178 151 208 170 260 284 246 181 243 172 266 236 ...
output:
result:
Test #25:
score: 0
Time Limit Exceeded
input:
215 217 209 191 244 274 188 234 184 252 157 299 258 184 267 153 221 273 184 153 177 256 262 289 175 ...
output:
result:
Test #26:
score: 0
Time Limit Exceeded
input:
295 225 233 208 271 187 236 241 189 219 292 252 168 264 283 233 221 205 167 234 287 243 220 158 175 ...
output:
result:
Test #27:
score: 0
Time Limit Exceeded
input:
299 203 291 213 266 297 203 247 211 247 215 263 197 222 284 279 226 184 225 274 191 189 264 233 239 ...
output:
result:
Test #28:
score: 0
Time Limit Exceeded
input:
282 260 226 253 169 172 246 180 235 158 241 291 265 217 293 200 291 192 150 162 296 234 199 214 241 ...
output:
result:
Test #29:
score: 0
Time Limit Exceeded
input:
253 213 169 271 234 196 242 162 174 279 252 226 278 274 299 275 183 190 251 152 284 172 172 219 282 ...
output:
result:
Test #30:
score: 0
Time Limit Exceeded
input:
244 261 208 209 266 233 251 167 263 257 252 187 287 208 201 195 287 257 156 266 155 300 233 210 297 ...
output:
result:
Test #31:
score: 0
Time Limit Exceeded
input:
4 50744225 38575863 495383008 631106704 4 0 25 35 30 24
output:
result:
Test #32:
score: 0
Time Limit Exceeded
input:
4 673632204 632599294 87647500 259824460 4 40 0 30 45 157
output:
result:
Test #33:
score: 0
Time Limit Exceeded
input:
4 14299465 827073858 503533923 293157764 5 0 25 40 45 35 222
output:
result:
Test #34:
score: 0
Time Limit Exceeded
input:
4 663968026 24024344 854278647 369272663 5 35 0 25 45 40 82
output:
result:
Test #35:
score: 0
Time Limit Exceeded
input:
4 201480655 281570624 460966655 520615378 3 35 0 25 154
output:
result:
Test #36:
score: 0
Time Limit Exceeded
input:
4 102842920 576317606 634020368 916827654 2 0 30 119
output:
result:
Test #37:
score: 0
Time Limit Exceeded
input:
4 370588670 109359792 418934615 796823541 2 25 30 128
output:
result:
Test #38:
score: 0
Time Limit Exceeded
input:
4 531736881 952131467 688585945 313261542 6 40 45 30 35 0 25 78
output:
result:
Test #39:
score: 0
Time Limit Exceeded
input:
4 132751568 59366279 305927515 739539040 3 40 30 45 96
output:
result:
Test #40:
score: 0
Time Limit Exceeded
input:
4 285073926 640307115 356656822 327551729 6 40 25 30 0 45 35 155
output:
result:
Test #41:
score: 0
Time Limit Exceeded
input:
205 412930570 552629105 672175662 303694806 904807831 507202370 747835207 15071231 859893402 1380360...
output:
result:
Test #42:
score: 0
Time Limit Exceeded
input:
214 19482433 61432329 815160734 369893772 748103097 124250254 326720190 559458458 856249164 98995671...
output:
result:
Test #43:
score: 0
Time Limit Exceeded
input:
228 241116086 337844661 777859665 621930050 219124560 288532557 449893014 70007068 78311937 55092074...
output:
result:
Test #44:
score: 0
Time Limit Exceeded
input:
201 971257189 374045009 944462414 537953285 782273469 508697813 853375962 907670430 857179519 919125...
output:
result:
Test #45:
score: 0
Time Limit Exceeded
input:
242 41370261 713342743 734488650 964341025 444683786 352744376 520404685 481078811 240751328 3936243...
output:
result:
Test #46:
score: 0
Time Limit Exceeded
input:
212 460585228 988049100 554627029 805469349 677495536 196685890 50640467 688159933 87204763 63772004...
output:
result:
Test #47:
score: 0
Time Limit Exceeded
input:
264 144360415 304243545 861675592 116241251 61636172 671870370 967871925 500422194 63828918 53413669...
output:
result:
Test #48:
score: 0
Time Limit Exceeded
input:
292 884038219 292746082 444330474 653054716 823793789 883470573 289247597 937444397 512144383 736086...
output:
result:
Test #49:
score: 0
Time Limit Exceeded
input:
277 524512852 625493914 894422617 887636172 738205289 547388902 688301140 338861248 972926334 310518...
output:
result:
Test #50:
score: 0
Time Limit Exceeded
input:
300 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870911 536870...