Submission #736144

# Submission time Handle Problem Language Result Execution time Memory
736144 2023-05-05T09:04:53 Z marvinthang Zapina (COCI20_zapina) C++17
0 / 110
2 ms 340 KB
/******************************
*    author : @marvinthang    *
*    date : 14 / 11 / 2021    *
******************************/
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define  superspeed  ios_base::sync_with_stdio(false);\
                     cin.tie(NULL);\
                     //cout.tie(NULL);
#define  file(name)  freopen(name".inp", "r", stdin);\
                     freopen(name".out", "w", stdout);
 
const       int MOD = 1e9 + 7; // 998244353;
const     double PI = 3.1415926535897932384626433832795; // acos((db)-1); atan(-1.0);
const      int dx[] = {-1, 0, 1, 0}, dy[] = {0, 1, 0, -1};
const  long long oo = 1e18;
const       int MAX = 355;
 
void add(int &a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
}
 
int N, F[MAX][MAX][2], comb[MAX][MAX];
 
void prepare() {
    comb[0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        comb[0][i] = 1;
        for (int j = 1; j <= i; ++j) {
            comb[j][i] = comb[j][i - 1];
            add(comb[j][i], comb[j - 1][i - 1]);
        }
    }
}
 
int main() {
    superspeed;
#ifndef ONLINE_JUDGE
	file("HAPPY");
#endif
    cin >> N;
    prepare();
    F[0][0][0] = 1;
    for (int i = 1; i <= N; ++i) {
        for (int j = 0; j <= N; ++j) {
            if (j >= i) add(F[i][j][1], 1LL * comb[i][j] * F[i - 1][j - i][0] % MOD);
            for (int k = 0; k <= j; ++k) {
                if (k != i) add(F[i][j][0], 1LL * comb[k][j] * F[i - 1][j - k][0] % MOD);
                add(F[i][j][1], 1LL * comb[k][j] * F[i - 1][j - k][1] % MOD);
            }
        }
    }
    cout << F[N][N][1] << '\n';
    return 0;
}

Compilation message

zapina.cpp: In function 'int main()':
zapina.cpp:13:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   13 | #define  file(name)  freopen(name".inp", "r", stdin);\
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
zapina.cpp:43:2: note: in expansion of macro 'file'
   43 |  file("HAPPY");
      |  ^~~~
zapina.cpp:14:29: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   14 |                      freopen(name".out", "w", stdout);
      |                      ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
zapina.cpp:43:2: note: in expansion of macro 'file'
   43 |  file("HAPPY");
      |  ^~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -