45652023-03-29 21:14:36Valaki2Járdakövezés háromféle elemmelcpp14Accepted 30/304ms5936 KiB
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define fi first
#define se second

const int mod = 2023;

void solve() {
    int n;
    cin >> n;
    vector<int> fel(1 + n, 0), egesz(1 + n, 0), reszfel(1 + n, 0);
    egesz[0] = 1;
    fel[1] = 1;
    egesz[1] = 2;
    for(int i = 2; i <= n; i++) {
        reszfel[i] = (fel[i - 1] + egesz[i - 2]) % mod;
        // ez tuti jo
        fel[i] = (egesz[i - 1] + fel[i - 1] + egesz[i - 2]) % mod;
        // ketszer szamoljuk: ha ket kicsi van a legvegen
        egesz[i] = (2 * egesz[i - 1] + egesz[i - 2] + 2 * reszfel[i] + 2 * fel[i - 1]) % mod;
    }
    cout << egesz[n] << "\n";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1976 KiB
2Accepted0/02ms2204 KiB
3Accepted2/22ms2420 KiB
4Accepted2/23ms2520 KiB
5Accepted2/23ms2656 KiB
6Accepted2/23ms2848 KiB
7Accepted2/22ms2980 KiB
8Accepted2/22ms3192 KiB
9Accepted2/23ms3856 KiB
10Accepted2/23ms4036 KiB
11Accepted2/24ms4888 KiB
12Accepted3/34ms5464 KiB
13Accepted3/33ms3788 KiB
14Accepted3/33ms3940 KiB
15Accepted3/34ms5936 KiB