Submission #994063


Source Code Expand

#include <cstdio>
#include <memory.h>
using namespace std;

const int N = 305;

int C[N][N];

const int MOD = 1000 * 1000 * 1000 + 7;

typedef long long llong;

inline int add(int x, int y) {
    return (x + y) % MOD;
}

inline int mul(int a, int b) {
    return (((llong)a) * b) % MOD;
}

llong D[N][N];
llong pD[N][N];

void init() {
    for (int n = 0; n < N; n++) {
        C[n][0] = C[n][n] = 1;
        for (int k = 1; k < n; k++)
            C[n][k] = add(C[n - 1][k - 1], C[n - 1][k]);
    }
}

int main() {
    int n, m;
    scanf("%d %d", &n, &m);
    init();
    D[1][1] = 1;
    for (int i = 1; i < m; i++) {
        memcpy(pD, D, sizeof(D));
        for (int b = 0; b <= n; b++)
            for (int a = b; a <= n; a++)
                D[b][a] = 0;
        for (int b = 1; b <= n; b++) {
            for (int a = b; a <= n; a++) {
                int val = pD[b][a];
                if (a + 1 <= n)
                    D[b + 1][a + 1] = add(D[b + 1][a + 1], mul(val, n - a));
                if (a + 1 <= n)
                    D[b][a + 1] = add(D[b][a + 1], mul(val, n - a));
                if (b >= 2)
                    D[b - 1][a] = add(D[b - 1][a], mul(val, b));

                D[b][a] = add(D[b][a], mul(val, b));
            }
        }
    }
    int ans = D[1][n];
    printf("%d\n", ans);
}

Submission Info

Submission Time
Task F - Road of the King
User Zlobober
Language C++14 (GCC 5.4.1)
Score 1000
Code Size 1375 Byte
Status AC
Exec Time 212 ms
Memory 1920 KB

Compile Error

./Main.cpp: In function ‘int main()’:
./Main.cpp:34:27: warning: ignoring return value of ‘int scanf(const char*, ...)’, declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d", &n, &m);
                           ^

Judge Result

Set Name sample all
Score / Max Score 0 / 0 1000 / 1000
Status
AC × 3
AC × 13
Set Name Test Cases
sample sample-01.txt, sample-02.txt, sample-03.txt
all sample-01.txt, sample-02.txt, sample-03.txt, 01-01.txt, 01-02.txt, 01-03.txt, 01-04.txt, 01-05.txt, 01-06.txt, 01-07.txt, 01-08.txt, 01-09.txt, 01-10.txt
Case Name Status Exec Time Memory
01-01.txt AC 2 ms 640 KB
01-02.txt AC 3 ms 1280 KB
01-03.txt AC 14 ms 1280 KB
01-04.txt AC 2 ms 512 KB
01-05.txt AC 14 ms 1280 KB
01-06.txt AC 32 ms 1408 KB
01-07.txt AC 199 ms 1920 KB
01-08.txt AC 210 ms 1920 KB
01-09.txt AC 211 ms 1920 KB
01-10.txt AC 212 ms 1920 KB
sample-01.txt AC 3 ms 1280 KB
sample-02.txt AC 65 ms 1664 KB
sample-03.txt AC 108 ms 1920 KB