QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#190537 | #3669. Counting Stairs | maghrabyJr_# | WA | 20ms | 394208kb | C++20 | 821b | 2023-09-29 03:21:33 | 2023-09-29 03:21:34 |
Judging History
answer
#include "bits/stdc++.h"
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
using namespace std;
const int MOD = 998244353;
const int N= 2e5 + 10;
int dp[500][N];
int solve(int places, int sum){
if(sum == 0) return 1;
if(sum < 0 || places < 0) return 0;
int &ret= dp[places][sum];
if(ret != -1)
return ret;
int ch1= solve(places - 2, sum);
int ch2= solve(places - 2, sum - places);
return ret= (ch1 + ch2) % MOD;
}
int32_t main(){
cin.tie(0);
cin.sync_with_stdio(0);
::memset(dp, -1, sizeof dp);
int T; cin>>T;
while(T--)
{
int n; cin>>n;
cout<<solve(499, n)<<"\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 19ms
memory: 394084kb
input:
4 3 5 17 25
output:
1 1 5 12
result:
ok 4 number(s): "1 1 5 12"
Test #2:
score: 0
Accepted
time: 15ms
memory: 394180kb
input:
10 1 2 3 4 5 6 7 8 9 10
output:
1 0 1 1 1 1 1 2 2 2
result:
ok 10 numbers
Test #3:
score: 0
Accepted
time: 20ms
memory: 394100kb
input:
100 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
output:
1 0 1 1 1 1 1 2 2 2 2 3 3 3 4 5 5 5 6 7 8 8 9 11 12 12 14 16 17 18 20 23 25 26 29 33 35 37 41 46 49 52 57 63 68 72 78 87 93 98 107 117 125 133 144 157 168 178 192 209 223 236 255 276 294 312 335 361 385 408 437 471 501 530 568 609 647 686 732 784 833 881 939 1004 1065 1126 1199 1279 1355 1433 1523 1...
result:
ok 100 numbers
Test #4:
score: -100
Wrong Answer
time: 12ms
memory: 394208kb
input:
1000 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101...
output:
1 0 1 1 1 1 1 2 2 2 2 3 3 3 4 5 5 5 6 7 8 8 9 11 12 12 14 16 17 18 20 23 25 26 29 33 35 37 41 46 49 52 57 63 68 72 78 87 93 98 107 117 125 133 144 157 168 178 192 209 223 236 255 276 294 312 335 361 385 408 437 471 501 530 568 609 647 686 732 784 833 881 939 1004 1065 1126 1199 1279 1355 1433 1523 1...
result:
wrong answer 501st numbers differ - expected: '179554368', found: '179554367'