QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#448686 | #8702. 狼人杀 | RedreamMer | 100 ✓ | 848ms | 112996kb | C++17 | 2.0kb | 2024-06-19 22:25:32 | 2024-06-19 22:25:32 |
Judging History
answer
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cmath>
#include <vector>
#include <cstdio>
#include <random>
#include <iomanip>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <unordered_map>
using namespace std;
#define PB emplace_back
#define int long long
#define ll long long
#define vi vector<int>
#define siz(a) ((int) ((a).size()))
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)
void print(vi n) { rep(i, 0, siz(n) - 1) cerr << n[i] << " \n"[i == siz(n) - 1]; }
const int N = 150, mod = 1e9 + 7;
int a, b, f[2][N + 5][N * N + 5][2];
bool vis[N + 5];
int qp(int n, int m = mod - 2) {
int res = 1;
for (; m; m >>= 1) {
if (m & 1) res = res * n % mod;
n = n * n % mod;
}
return res;
}
int S(int n) {return n * (n + 1) / 2 % mod;}
void add(int &n, int m) {
n += m;
if(n >= mod) n -= mod;
}
signed main() {
// freopen(".in", "r", stdin);
// freopen(".out", "w", stdout);
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
cin >> a >> b;
b = a - b + 1;
f[0][0][0][0] = mod - 1;
int sum = a * (a + 1) / 2 % mod, now = 0;
rep(i, 0, a - 1) {
memset(f[now ^ 1], 0, sizeof(f[now ^ 1]));
rep(j, 0, i) rep(k, 0, sum) rep(o, 0, 1) if(f[now][j][k][o]) {
add(f[now ^ 1][j][k + i + 1 - j][o], f[now][j][k][o]);
if(!o && i + 1 != b) add(f[now ^ 1][j][k + i + 1 - j][1], f[now][j][k][o]);
if(i + 1 != b) add(f[now ^ 1][i + 1][k][o], mod - f[now][j][k][o]);
}
now ^= 1;
}
int ans = 0;
rep(j, 0, a) rep(i, 0, sum - 1) if(f[now][j][i][1]) {
// cout << j << ' ' << i << ' ' << f[now][j][i][1] << endl;
(ans += f[now][j][i][1] * sum % mod * qp(sum - i + mod)) %= mod;
}
cout << ans * qp(a - 1) % mod;
return cerr << endl << 1.0 * clock() / CLOCKS_PER_SEC << endl, 0;
}
Details
Tip: Click on the bar to expand more detailed information
Subtask #1:
score: 23
Accepted
Test #1:
score: 23
Accepted
time: 53ms
memory: 112912kb
input:
12 2
output:
183756997
result:
ok single line: '183756997'
Test #2:
score: 0
Accepted
time: 57ms
memory: 112932kb
input:
17 6
output:
97571903
result:
ok single line: '97571903'
Test #3:
score: 0
Accepted
time: 48ms
memory: 112980kb
input:
13 3
output:
209826617
result:
ok single line: '209826617'
Test #4:
score: 0
Accepted
time: 48ms
memory: 112984kb
input:
13 8
output:
176038768
result:
ok single line: '176038768'
Test #5:
score: 0
Accepted
time: 67ms
memory: 112992kb
input:
18 4
output:
288404061
result:
ok single line: '288404061'
Test #6:
score: 0
Accepted
time: 32ms
memory: 112916kb
input:
10 10
output:
219657163
result:
ok single line: '219657163'
Test #7:
score: 0
Accepted
time: 64ms
memory: 112976kb
input:
19 15
output:
590577825
result:
ok single line: '590577825'
Test #8:
score: 0
Accepted
time: 35ms
memory: 112976kb
input:
11 6
output:
488143489
result:
ok single line: '488143489'
Test #9:
score: 0
Accepted
time: 36ms
memory: 112972kb
input:
10 5
output:
470594541
result:
ok single line: '470594541'
Test #10:
score: 0
Accepted
time: 75ms
memory: 112988kb
input:
20 5
output:
582458555
result:
ok single line: '582458555'
Test #11:
score: 0
Accepted
time: 72ms
memory: 112984kb
input:
20 12
output:
648081410
result:
ok single line: '648081410'
Test #12:
score: 0
Accepted
time: 69ms
memory: 112916kb
input:
20 4
output:
335777285
result:
ok single line: '335777285'
Test #13:
score: 0
Accepted
time: 66ms
memory: 112980kb
input:
20 15
output:
389216500
result:
ok single line: '389216500'
Test #14:
score: 0
Accepted
time: 73ms
memory: 112920kb
input:
20 16
output:
582458555
result:
ok single line: '582458555'
Test #15:
score: 0
Accepted
time: 73ms
memory: 112940kb
input:
20 19
output:
589126150
result:
ok single line: '589126150'
Test #16:
score: 0
Accepted
time: 66ms
memory: 112976kb
input:
20 6
output:
389216500
result:
ok single line: '389216500'
Subtask #2:
score: 34
Accepted
Dependency #1:
100%
Accepted
Test #17:
score: 34
Accepted
time: 184ms
memory: 112972kb
input:
49 14
output:
486918542
result:
ok single line: '486918542'
Test #18:
score: 0
Accepted
time: 109ms
memory: 112980kb
input:
28 13
output:
642223597
result:
ok single line: '642223597'
Test #19:
score: 0
Accepted
time: 132ms
memory: 112988kb
input:
35 23
output:
842346505
result:
ok single line: '842346505'
Test #20:
score: 0
Accepted
time: 181ms
memory: 112924kb
input:
47 11
output:
583647040
result:
ok single line: '583647040'
Test #21:
score: 0
Accepted
time: 129ms
memory: 112924kb
input:
34 30
output:
990970048
result:
ok single line: '990970048'
Test #22:
score: 0
Accepted
time: 105ms
memory: 112992kb
input:
30 7
output:
393675971
result:
ok single line: '393675971'
Test #23:
score: 0
Accepted
time: 167ms
memory: 112976kb
input:
43 5
output:
737421246
result:
ok single line: '737421246'
Test #24:
score: 0
Accepted
time: 128ms
memory: 112988kb
input:
30 21
output:
254760745
result:
ok single line: '254760745'
Test #25:
score: 0
Accepted
time: 111ms
memory: 112976kb
input:
27 22
output:
266692865
result:
ok single line: '266692865'
Test #26:
score: 0
Accepted
time: 155ms
memory: 112992kb
input:
40 12
output:
133652311
result:
ok single line: '133652311'
Test #27:
score: 0
Accepted
time: 106ms
memory: 112988kb
input:
29 4
output:
873892090
result:
ok single line: '873892090'
Test #28:
score: 0
Accepted
time: 187ms
memory: 112912kb
input:
50 46
output:
267950067
result:
ok single line: '267950067'
Test #29:
score: 0
Accepted
time: 198ms
memory: 112988kb
input:
50 11
output:
423642322
result:
ok single line: '423642322'
Test #30:
score: 0
Accepted
time: 200ms
memory: 112936kb
input:
50 43
output:
625476642
result:
ok single line: '625476642'
Test #31:
score: 0
Accepted
time: 192ms
memory: 112936kb
input:
50 36
output:
767166129
result:
ok single line: '767166129'
Test #32:
score: 0
Accepted
time: 193ms
memory: 112988kb
input:
50 14
output:
357467965
result:
ok single line: '357467965'
Test #33:
score: 0
Accepted
time: 186ms
memory: 112848kb
input:
50 30
output:
219673347
result:
ok single line: '219673347'
Test #34:
score: 0
Accepted
time: 189ms
memory: 112980kb
input:
50 44
output:
392786132
result:
ok single line: '392786132'
Test #35:
score: 0
Accepted
time: 188ms
memory: 112932kb
input:
50 10
output:
848251616
result:
ok single line: '848251616'
Subtask #3:
score: 43
Accepted
Dependency #1:
100%
Accepted
Dependency #2:
100%
Accepted
Test #36:
score: 43
Accepted
time: 299ms
memory: 112972kb
input:
75 47
output:
668751416
result:
ok single line: '668751416'
Test #37:
score: 0
Accepted
time: 304ms
memory: 112920kb
input:
75 41
output:
310834114
result:
ok single line: '310834114'
Test #38:
score: 0
Accepted
time: 675ms
memory: 112980kb
input:
133 124
output:
57167600
result:
ok single line: '57167600'
Test #39:
score: 0
Accepted
time: 636ms
memory: 112908kb
input:
129 74
output:
751074385
result:
ok single line: '751074385'
Test #40:
score: 0
Accepted
time: 689ms
memory: 112932kb
input:
135 133
output:
759430862
result:
ok single line: '759430862'
Test #41:
score: 0
Accepted
time: 312ms
memory: 112984kb
input:
75 19
output:
967921272
result:
ok single line: '967921272'
Test #42:
score: 0
Accepted
time: 591ms
memory: 112788kb
input:
124 9
output:
641081661
result:
ok single line: '641081661'
Test #43:
score: 0
Accepted
time: 304ms
memory: 112792kb
input:
76 66
output:
465902083
result:
ok single line: '465902083'
Test #44:
score: 0
Accepted
time: 748ms
memory: 112932kb
input:
142 13
output:
12401929
result:
ok single line: '12401929'
Test #45:
score: 0
Accepted
time: 839ms
memory: 112932kb
input:
150 5
output:
388058135
result:
ok single line: '388058135'
Test #46:
score: 0
Accepted
time: 489ms
memory: 112920kb
input:
109 97
output:
381109644
result:
ok single line: '381109644'
Test #47:
score: 0
Accepted
time: 843ms
memory: 112920kb
input:
150 133
output:
174431234
result:
ok single line: '174431234'
Test #48:
score: 0
Accepted
time: 848ms
memory: 112976kb
input:
150 147
output:
198921722
result:
ok single line: '198921722'
Test #49:
score: 0
Accepted
time: 839ms
memory: 112988kb
input:
150 142
output:
631473185
result:
ok single line: '631473185'
Test #50:
score: 0
Accepted
time: 845ms
memory: 112996kb
input:
150 136
output:
743180069
result:
ok single line: '743180069'
Test #51:
score: 0
Accepted
time: 841ms
memory: 112928kb
input:
150 138
output:
621574340
result:
ok single line: '621574340'
Test #52:
score: 0
Accepted
time: 838ms
memory: 112980kb
input:
150 119
output:
872660153
result:
ok single line: '872660153'
Test #53:
score: 0
Accepted
time: 839ms
memory: 112992kb
input:
150 144
output:
939939060
result:
ok single line: '939939060'
Test #54:
score: 0
Accepted
time: 845ms
memory: 112916kb
input:
150 1
output:
166208360
result:
ok single line: '166208360'
Test #55:
score: 0
Accepted
time: 835ms
memory: 112848kb
input:
150 75
output:
353929212
result:
ok single line: '353929212'