QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#110572#2573. Two PermutationsyllcmWA 14ms14004kbC++171.5kb2023-06-02 21:26:512023-06-02 21:26:53

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-02 21:26:53]
  • 评测
  • 测评结果:WA
  • 用时:14ms
  • 内存:14004kb
  • [2023-06-02 21:26:51]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define db double
#define ldb long double
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define FR first
#define SE second
using namespace std;
inline int read() {
    int x = 0; bool op = 0;
    char c = getchar();
    while(!isdigit(c))op |= (c == '-'), c = getchar();
    while(isdigit(c))x = (x << 1) + (x << 3) + (c ^ 48), c = getchar();
    return op ? -x : x;
}
const int N = 110;
const int P = 1e9 + 7;
void add(int &a, int b) {a += b; a >= P ? a -= P : 0;}
void sub(int &a, int b) {a -= b; a < 0 ? a += P : 0;}
int n, k;
int f[2][N][N * N];
int main() { 
    n = read(); k = read();
    f[1][0][0] = 1;
    for(int i = 1; i <= n; i++) {
        swap(f[0], f[1]);
        for(int x = 0; x <= i; x++)for(int z = 0; z <= i * i; z++)f[1][x][z] = 0;
        for(int x = 0; x <= i; x++) {
            for(int z = 0; z <= i * i; z++) {
                int y = i - 1 - x;
                if(f[0][x][z] == 0)continue;
                // cout << i << ' ' << x << ' ' << y << ' ' << z << ' ' << f[0][x][z] << endl;
                add(f[1][x + 1][z + i], 1ll * (n - x - 2 * y) * f[0][x][z] % P);
                add(f[1][x][z], 1ll * ((n - x - y) * (n - x - y) - (n - x - 2 * y)) % P * f[0][x][z] % P);
                add(f[1][x + 2][z + 2 * i], 1ll * y * y % P * f[0][x][z] % P);
                add(f[1][x + 1][z + i], 2ll * (n - x - y) * y % P * f[0][x][z] % P);
            }
        }
    }
    printf("%d\n", f[1][n][k]);
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 4ms
memory: 13860kb

input:

2 4

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 14ms
memory: 14004kb

input:

3 7

output:

12

result:

ok 1 number(s): "12"

Test #3:

score: 0
Accepted
time: 10ms
memory: 13892kb

input:

4 10

output:

24

result:

ok 1 number(s): "24"

Test #4:

score: -100
Wrong Answer
time: 2ms
memory: 13940kb

input:

4 14

output:

336

result:

wrong answer 1st numbers differ - expected: '96', found: '336'