QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#485375 | #8049. Equal Sums | EasonLiang | WA | 1ms | 4552kb | C++14 | 2.3kb | 2024-07-20 17:19:16 | 2024-07-20 17:19:17 |
Judging History
answer
#include <bits/stdc++.h>
#define FileIO_(file) \
freopen (file ".in", "r", stdin); \
freopen (file ".out", "w", stdout);
using namespace std;
template<typename Tp>
inline void chmin (Tp &x, const Tp &y) { if (y < x) x = y; }
template<typename Tp>
inline void chmax (Tp &x, const Tp &y) { if (x < y) x = y; }
typedef double dbl;
typedef long long ll;
typedef long double ldb;
const ll mod = 1e9 + 7;
const int maxn = 3e2 + 20;
const int maxm = 3e2 + 20;
const int maxa = 3e2 + 20;
int n, m, al[maxn], ar[maxn], bl[maxm], br[maxm];
ll dp[maxn][maxm][2 * maxa];
void init () {}
void add (ll &x, const ll &y) {
if ((x += y) >= mod) x -= mod;
}
void sub (ll &x, const ll &y) {
if ((x -= y) < 0) x += mod;
}
void solve () {
scanf ("%d%d", &n, &m);
for (int i = 1; i <= n; ++i) {
scanf ("%d%d", &al[i], &ar[i]);
}
for (int i = 1; i <= m; ++i) {
scanf ("%d%d", &bl[i], &br[i]);
}
dp[0][0][maxa] = 1ll;
dp[0][0][maxa + 1] = -1ll;
for (int i = 0; i <= n; ++i) {
for (int j = 0; j <= m; ++j) {
for (int v = 1; v < maxa; ++v) {
add (dp[i][j][v], dp[i][j][v - 1]);
add (dp[i + 1][j][v + al[i + 1]], dp[i][j][v]);
sub (dp[i + 1][j][v + ar[i + 1] + 1], dp[i][j][v]);
}
for (int v = maxa; v < 2 * maxa; ++v) {
add (dp[i][j][v], dp[i][j][v - 1]);
add (dp[i][j + 1][v - br[j + 1]], dp[i][j][v]);
sub (dp[i][j + 1][v - bl[j + 1] + 1], dp[i][j][v]);
}
}
}
for (int i = 1; i <= n; ++i) {
for (int j = 1; j <= m; ++j) {
printf ("%lld ", dp[i][j][maxa]);
}
puts ("");
}
}
int main () {
// #ifndef LSY
// FileIO_("");
// #endif
int t = 1; init ();
// scanf ("%d", &t);
while (t--) solve ();
return 0;
}
// #ifdef LSY
// bool ed, debug = [] () {
// static bool st; int memtyp = 0; dbl memsiz = &st - &ed;
// static const string memstr[] = {"B", "KB", "MB", "GB"};
// while (memsiz >= 1024.) { ++memtyp; memsiz /= 1024.; }
// cerr << "Memory: " << memsiz << memstr[memtyp] << endl;
// return atexit ([] () { cerr << "Time: " << 1000. *
// clock () / CLOCKS_PER_SEC << "ms" << endl; });
// } ();
// #endif
詳細信息
Test #1:
score: 100
Accepted
time: 1ms
memory: 3956kb
input:
2 3 1 2 2 3 1 4 2 2 1 3
output:
2 0 0 3 4 4
result:
ok 6 numbers
Test #2:
score: -100
Wrong Answer
time: 1ms
memory: 4552kb
input:
500 500 19 458 1 480 7 485 50 461 12 476 15 461 48 466 40 453 46 467 9 458 27 478 26 472 46 459 29 490 6 500 17 487 48 484 28 472 28 459 25 480 4 491 29 481 36 460 2 491 44 499 22 473 20 458 4 483 27 471 2 496 11 461 43 450 2 478 37 466 15 459 42 482 7 451 19 455 2 453 47 475 48 450 1 474 46 471 9 4...
output:
0 999347626 517184425 527219834 0 865215887 701260729 178798000 0 502585722 305867016 103116094 0 898634183 788966035 895137740 0 875975718 399517292 894363376 0 461562433 459294888 100656680 0 173336612 623023785 136659776 0 312210462 891079875 550029057 0 72717524 101643619 396254969 0 68...
result:
wrong answer 1st numbers differ - expected: '411', found: '0'