78842024-01-11 17:55:07adamFasor (40)cpp17Wrong answer 0/4035ms38792 KiB
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>> dp;

int calculate (int n, int space) {
    if (n < 0)  return 0;
    else if (n == 0 && space == 0) return 1;


    if (dp[n][space] != -1) return dp[n][space];
    int answer = 0;
    if (space == 2) {
        answer += calculate(n, 0); // fektettett
    } else if (space == 1) {
        answer += calculate(n-1, 1); // fektetett
        answer += calculate(n-1, 0); // L
    }else if (space == 0) {
        answer += calculate(n - 1, 0); // allitott
        answer += calculate(n - 2, 2); // fektettett
        answer += calculate(n - 2, 1) * 2; // L
    }

    return dp[n][space] = answer;
}

int main() {
    int n;
    cin >> n;
    dp.assign(n+1, vector(3, -1));

    cout << calculate(n, 0) << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base0/40
1Wrong answer0/03ms1960 KiB
2Wrong answer0/04ms3608 KiB
3Wrong answer0/23ms2320 KiB
4Wrong answer0/23ms2404 KiB
5Wrong answer0/23ms2336 KiB
6Wrong answer0/23ms2452 KiB
7Wrong answer0/23ms2872 KiB
8Wrong answer0/23ms3296 KiB
9Wrong answer0/24ms4624 KiB
10Wrong answer0/24ms4792 KiB
11Wrong answer0/24ms4928 KiB
12Wrong answer0/24ms5088 KiB
13Wrong answer0/217ms20768 KiB
14Wrong answer0/218ms20692 KiB
15Wrong answer0/232ms37788 KiB
16Wrong answer0/232ms38080 KiB
17Wrong answer0/235ms38316 KiB
18Wrong answer0/232ms38288 KiB
19Wrong answer0/235ms38524 KiB
20Wrong answer0/217ms21800 KiB
21Wrong answer0/235ms38756 KiB
22Wrong answer0/235ms38792 KiB