Submission #31034927


Source Code Expand

Copy
/*
//#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
*/
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
/*
//#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
*/

#include <bits/stdc++.h>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 20;
const ll INF = 1e16;
//const ll MOD = 1e9+7;
//const ll MOD = 998244353;

void setIO()
{
    FAST_IO;
}

void setIO(string s)
{
    FAST_IO;
    freopen((s+".in").c_str(), "r", stdin);
    freopen((s+".out").c_str(), "w", stdout);
}

ll dp[2*3100][2*3100][2];
int n;
ll p;

int main()
{
    setIO();

    cin >> n >> p;

    dp[1][0][1] = dp[1][1][0] = 1;

    FOR(i, 2, n) FOR(cnt, 0, n-1) {
        if (cnt >= 1) dp[i][cnt][0] += dp[i-1][cnt-1][0];
        if (cnt >= 2) dp[i][cnt][0] += 2*dp[i-1][cnt-2][1];

        dp[i][cnt][1] = dp[i-1][cnt][0] + dp[i-1][cnt][1];
        if (cnt >= 1) dp[i][cnt][1] += dp[i-1][cnt-1][1];
        if (cnt >= 1) dp[i][cnt][1] += 2*dp[i-1][cnt-1][1];

        FOR(k, 0, 1) dp[i][cnt][k] %= p;

        //cout << " i=" << i << " cnt = " << cnt << " dp0 = "
        //<< dp[i][cnt][0] << "  dp1 = " << dp[i][cnt][1] << endl;
    }

    FOR(cnt, 1, n-1) cout << (dp[n][cnt][1]%p) << " ";
    cout << "\n";

    return 0;
}

Submission Info

Submission Time
Task F - Keep Connect
User Aldas25
Language C++ (GCC 9.2.1)
Score 500
Code Size 1633 Byte
Status AC
Exec Time 301 ms
Memory 155948 KB

Compile Error

./Main.cpp: In function ‘void setIO(std::string)’:
./Main.cpp:38:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   38 |     freopen((s+".in").c_str(), "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
./Main.cpp:39:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’, declared with attribute warn_unused_result [-Wunused-result]
   39 |     freopen((s+".out").c_str(), "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 500 / 500
Status
AC × 2
AC × 20
Set Name Test Cases
Sample example_00.txt, example_01.txt
All example_00.txt, example_01.txt, hand_00.txt, hand_01.txt, hand_02.txt, hand_03.txt, hand_04.txt, hand_05.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt
Case Name Status Exec Time Memory
example_00.txt AC 8 ms 3440 KB
example_01.txt AC 2 ms 3488 KB
hand_00.txt AC 6 ms 3440 KB
hand_01.txt AC 3 ms 3480 KB
hand_02.txt AC 3 ms 3528 KB
hand_03.txt AC 299 ms 155948 KB
hand_04.txt AC 301 ms 155936 KB
hand_05.txt AC 299 ms 155508 KB
random_00.txt AC 150 ms 78868 KB
random_01.txt AC 118 ms 62196 KB
random_02.txt AC 271 ms 140836 KB
random_03.txt AC 285 ms 148208 KB
random_04.txt AC 7 ms 4592 KB
random_05.txt AC 297 ms 153924 KB
random_06.txt AC 275 ms 144460 KB
random_07.txt AC 288 ms 149868 KB
random_08.txt AC 215 ms 112080 KB
random_09.txt AC 259 ms 133532 KB
random_10.txt AC 295 ms 154592 KB
random_11.txt AC 282 ms 148460 KB


2025-03-02 (Sun)
08:34:53 +00:00