70952023-12-30 11:30:031478Járda-L (40)cpp17Accepted 40/403ms4260 KiB
#include <bits/stdc++.h>  
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 998244353;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
int main()
{
    //ifstream cin("in.txt");
    int n;
    cin >> n;

    vector<int> dpFull(n + 1);
    dpFull[1] = 1;
    dpFull[2] = 2;

    vector<int> dpMissUp(n + 1);
    vector<int> dpMissDown(n + 1);

    dpMissUp[2] = 1;
    dpMissDown[2] = 1;

    for(int i = 3; i <= n; i++){

        //szimmetrikus ez a ketto
        dpMissUp[i] = dpMissDown[i - 1] + dpFull[i - 2];
        dpMissDown[i] = dpMissUp[i - 1] + dpFull[i - 2];

        dpFull[i] = dpMissUp[i - 1] + dpMissDown[i - 1] + dpFull[i - 1] + dpFull[i - 2];
    }

    cout << dpFull[n];
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1808 KiB
2Accepted0/03ms2000 KiB
3Accepted2/23ms2216 KiB
4Accepted2/23ms2300 KiB
5Accepted2/23ms2428 KiB
6Accepted2/23ms2676 KiB
7Accepted2/23ms2720 KiB
8Accepted3/33ms2860 KiB
9Accepted3/33ms3108 KiB
10Accepted3/33ms3232 KiB
11Accepted3/33ms3464 KiB
12Accepted3/33ms3548 KiB
13Accepted3/33ms3764 KiB
14Accepted3/33ms4152 KiB
15Accepted3/33ms4188 KiB
16Accepted3/33ms4084 KiB
17Accepted3/33ms4260 KiB