138132025-01-08 19:59:48horkaJárda-L (40)cpp17Accepted 40/401ms508 KiB
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int n; cin>>n;
    vector<array<int, 3>> dp(n+1);
    dp[0][0]=1;
    dp[1][0]=1;
    for(int i=2; i<=n; i++)
    {
        dp[i][0]+=dp[i-1][0];
        dp[i][0]+=dp[i-2][0];
        dp[i][0]+=dp[i-1][1];
        dp[i][0]+=dp[i-1][2];
        dp[i][1]+=dp[i-2][0];
        dp[i][1]+=dp[i-1][2];
        dp[i][2]+=dp[i-2][0];
        dp[i][2]+=dp[i-1][1];
    }
    cout<<dp[n][0]<<"\n";

}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms316 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms316 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms332 KiB
7Accepted2/21ms316 KiB
8Accepted3/31ms316 KiB
9Accepted3/31ms316 KiB
10Accepted3/31ms316 KiB
11Accepted3/31ms316 KiB
12Accepted3/31ms508 KiB
13Accepted3/31ms316 KiB
14Accepted3/31ms316 KiB
15Accepted3/31ms500 KiB
16Accepted3/31ms316 KiB
17Accepted3/31ms316 KiB