QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#656087 | #5169. 夹娃娃 | Butanlishi | 10 | 1129ms | 4008kb | C++14 | 2.0kb | 2024-10-19 11:16:53 | 2024-10-19 11:16:54 |
Judging History
answer
#include<bits/stdc++.h>
#define ld long double
#define ci const int
#define ll long long
#define fo(i,l,r) for(int i=(l);i<=(r);++i)
#define fu(i,l,r) for(int i=(l);i<(r);++i)
#define fd(i,l,r) for(int i=(l);i>=(r);--i)
#define P(x) __builtin_popcount(x)
#define gcd(x,y) __gcd(x,y)
using namespace std;
ci mod=998244353,N=1e6+5;
const ld eps=1e-9;
void _(int &a,int b){a=(a+b)%mod;}
mt19937 rad(chrono::steady_clock::now().time_since_epoch().count());
inline ll read(){ll u=0,f=1;char o;while((o=getchar())<48||o>57)if(o=='-')f=-1;u=(o^48);while((o=getchar())>=48&&o<=57)u=(u<<1)+(u<<3)+(o^48);return u*f;}
void write(ll x){if(x<0)putchar('-'),x=-x;if(x>9)write(x/10);putchar(x%10+48);}
bool ST;
int n,q,a[16];
int b[16][550],c[16][550];
namespace solve4
{
int f[16][525],qz[525];
char ch[N];
bool ty[N];
int main()
{
while(q--)
{
scanf("%s",ch+1);
ll m=read(),k=read();
memset(f,0,sizeof(f));
f[0][0]=1;
bool F=0;
fo(i,1,n)
{
ty[i]=ch[i]-'0';
ll num=c[i][1];
if(ty[i])
{
if(b[i][1]*c[i][1]<k)
{
F=1;
break;
}
ll up=(k+b[i][1]-1)/b[i][1];
m-=up*b[i][1];
if(m<0)break;
num-=up;
}
// cout<<i<<' '<<b[i][1]<<' '<<num<<'\n';
// fo(j,0,m)cout<<f[i-1][j]<<' ';cout<<'\n';
fo(j,0,m)
{
qz[j]=f[i-1][j];
if(j>=b[i][1])_(qz[j],qz[j-b[i][1]]);
f[i][j]=qz[j];
if(j>=b[i][1]*(num+1))_(f[i][j],-qz[j-b[i][1]*(num+1)]);
}
}
int ans=0;
if(!F&&m>=0)
{
fo(i,0,m)_(ans,f[n][i]);
}
cout<<(ans+mod)%mod<<'\n';
}
return 0;
}
}
bool ED;
signed main()
{cerr<<(&ST-&ED)/1048576.0<<'\n';
// freopen("1.in","r",stdin);
// freopen("1.out","w",stdout);
// freopen("doll.in","r",stdin);
// freopen("doll.out","w",stdout);
n=read();q=read();read();
bool F=0;
fo(i,1,n)
{
a[i]=read();
fo(j,1,a[i])b[i][j]=read(),c[i][j]=read();
if(a[i]!=1)F=1;
}
if(!F)return solve4::main();
/* while(q--)
{
}*/
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 0
Wrong Answer
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 3876kb
input:
1 521 998244353 39 520 520 11 22 414 8 95 18 229 356 26 407 316 10 24 26 19 61 11 130 482 476 420 15 192 193 208 24 19 233 494 217 275 294 26 28 439 20 272 277 28 198 5 335 22 8 28 17 154 78 6 13 175 17 2 5 477 256 200 4 1 36 427 371 439 23 10 65 426 25 24 27 121 29 28 13 12 453 0 520 1 1 519 1 1 51...
output:
result:
wrong answer 1st lines differ - expected: '38813347', found: ''
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #2:
0%
Subtask #4:
score: 10
Accepted
Test #9:
score: 10
Accepted
time: 1129ms
memory: 3964kb
input:
15 52099 998244353 1 9 3 1 9 4 1 9 2 1 8 10 1 4 4 1 3 1 1 2 5 1 4 9 1 1 4 1 9 4 1 7 6 1 1 6 1 2 5 1 5 2 1 3 5 101000000001010 516 1 010001001010101 520 2 000000101000001 519 2 101011111100011 518 1 010110001000111 520 2 000110111100111 516 1 000100101001011 519 3 000111001010011 518 1 00001110010111...
output:
993379058 496689529 866368587 797687294 481245176 481245176 39022588 269889529 552778235 769822588 331666941 99789529 903956470 112750588 756797435 519045176 870912000 361582588 594280447 494747647 597778941 178845176 435456000 493445999 461733882 308912117 271186941 496689529 919511294 85533882 894...
result:
ok 52099 lines
Test #10:
score: 10
Accepted
time: 73ms
memory: 3844kb
input:
15 52099 998244353 1 444 1 1 184 2 1 427 1 1 23 1 1 513 2 1 413 4 1 304 2 1 214 5 1 108 2 1 304 1 1 283 5 1 465 1 1 277 1 1 57 2 1 160 4 111010111100101 520 25 010010011100110 520 3 010000011011000 519 36 110011011100110 516 21 010110001101101 516 42 100001101000111 520 31 110001100010001 519 10 110...
output:
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...
result:
ok 52099 lines
Test #11:
score: 10
Accepted
time: 471ms
memory: 3916kb
input:
15 52099 998244353 1 5 5 1 43 5 1 25 5 1 30 3 1 34 4 1 32 3 1 45 4 1 27 4 1 30 5 1 22 2 1 26 4 1 5 4 1 23 2 1 13 1 1 3 3 010111011010001 519 2 101000001100000 518 66 001011100110000 518 52 001100000000010 520 42 000110000110100 518 40 100011100010011 518 34 101000111100000 520 9 101010011100100 519 ...
output:
11101681 0 0 0 1142004 0 36064398 16061763 2645108 0 0 10591435 746157 1803184 0 0 16192453 0 0 0 0 20456968 0 3582238 805462 14505464 0 0 0 0 0 0 0 26667881 0 0 0 0 0 0 4674341 0 0 0 0 0 0 0 0 0 0 0 21963213 8597667 4334676 43539633 0 0 0 0 0 2382160 5712673 2788111 1352473 0 0 0 0 0 0 0 0 47306134...
result:
ok 52099 lines
Test #12:
score: 10
Accepted
time: 209ms
memory: 4008kb
input:
10 52099 998244353 1 5 1 1 23 1 1 27 4 1 19 4 1 12 2 1 30 5 1 28 2 1 16 4 1 30 3 1 6 5 0011010111 519 23 0000001001 517 49 0010110011 517 60 0001111100 520 44 1101101010 518 37 1010011010 519 33 0010010001 519 43 0110001001 517 29 1110101110 518 38 1011010010 520 49 0000000011 520 29 0011111011 518 ...
output:
37275 0 0 0 0 0 0 0 0 0 79991 0 0 0 15342 0 0 0 20344 0 56202 0 0 0 50043 0 0 0 181532 0 0 0 0 52937 0 0 0 0 0 55478 56473 0 255272 0 22226 0 0 18671 236899 0 16685 0 0 31629 0 0 0 0 0 0 87684 0 0 84149 0 0 0 127178 0 0 0 0 0 0 0 0 0 0 0 159291 0 0 0 41794 70377 83979 0 0 56097 0 106432 0 0 0 0 1131...
result:
ok 52099 lines
Test #13:
score: 10
Accepted
time: 244ms
memory: 3956kb
input:
9 52099 998244353 1 18 1 1 8 3 1 36 5 1 47 2 1 47 3 1 34 3 1 38 5 1 35 5 1 45 5 110110111 520 8 001110101 519 42 010101000 516 37 101001001 516 9 110111111 518 33 100111010 519 41 000010000 520 116 010110110 519 25 001011011 517 17 001100000 517 104 000010101 518 79 111100110 517 34 011100111 516 1 ...
output:
5039 4726 0 24816 0 0 24712 0 19695 0 3683 0 13040 0 10500 23330 0 0 52779 0 3146 3023 8773 9949 0 0 0 11047 0 30494 0 6016 7291 0 6836 16605 0 0 0 0 6209 14419 0 0 0 14987 0 0 0 0 0 13850 0 0 0 0 4210 11509 0 43740 0 21261 0 74429 0 0 15553 0 5876 33640 0 0 0 12734 0 14637 0 39701 2277 0 0 0 0 0 0 ...
result:
ok 52099 lines
Test #14:
score: 10
Accepted
time: 2ms
memory: 3904kb
input:
1 1000 998244353 1 5 1 0 516 28 1 517 106 1 517 22 0 519 4 0 516 37 0 518 10 1 517 62 0 519 32 1 518 58 1 519 72 1 516 82 1 520 56 1 516 59 1 520 79 0 517 122 1 517 2 1 517 53 0 518 93 0 520 149 1 520 86 0 520 53 1 517 120 1 518 41 1 517 94 0 519 76 0 517 46 1 520 48 0 519 31 0 519 4 0 516 24 0 516 ...
output:
2 0 0 2 2 2 0 2 0 0 0 0 0 0 2 1 0 2 2 0 2 0 0 0 2 2 0 2 2 2 2 0 2 2 2 2 0 0 0 2 2 0 0 2 2 2 2 0 0 2 0 2 0 0 2 2 0 2 2 0 0 2 2 2 0 0 2 0 0 2 0 2 0 0 2 0 0 0 0 2 2 0 0 0 1 2 2 2 2 2 2 2 2 0 0 2 2 2 0 2 2 0 0 2 0 2 0 2 0 2 2 0 0 0 0 0 2 2 2 2 2 0 2 0 0 0 0 0 2 2 2 0 2 0 2 0 0 2 2 0 0 2 2 0 2 0 2 2 0 0 ...
result:
ok 1000 lines
Subtask #5:
score: 0
Skipped
Dependency #3:
0%
Subtask #6:
score: 0
Skipped
Dependency #4:
100%
Accepted
Dependency #5:
0%
Subtask #7:
score: 0
Skipped
Dependency #6:
0%