QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#643989#8049. Equal SumsUnrealityWA 1432ms998156kbC++202.1kb2024-10-16 09:23:132024-10-16 09:23:14

Judging History

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

  • [2024-10-16 09:23:14]
  • 评测
  • 测评结果:WA
  • 用时:1432ms
  • 内存:998156kb
  • [2024-10-16 09:23:13]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define _rep(i_,a_,b_) for(int i_ = (a_); i_ <= (b_); ++i_)
#define mid ((L+R) >> 1)
#define multiCase() int testCnt = in(); _rep(curCase,1,testCnt)
#ifdef ONLINE_JUDGE
#define debug(...) 0
#else
#define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#endif
using ll = long long;
using pii = pair<int,int>;

int in(void) { int x; scanf("%d", &x); return x; } ll inl(void) { ll x; scanf("%lld", &x); return x; }
void out(int x) { printf("%d ", x); } void outln(int x) { printf("%d\n", x); }
void out(ll x) { printf("%lld ", x); } void outln(ll x) { printf("%lld\n", x); }
template<typename T> void chkmax(T &a, const T &b) { a = max(a, b); } 
template<typename T> void chkmin(T &a, const T &b) { a = min(a, b); } 
const int p = 998244353, kN = 505;
int n, m;
int _f[kN][kN][kN * 2], *f[kN][kN];
int la[kN], ra[kN], lb[kN], rb[kN];
int main() {
	n = in(), m = in(); int v = 500;
	_rep(i,0,kN - 1) _rep(j,0,kN - 1) f[i][j] = _f[i][j] + kN;
	_rep(i,1,n) la[i] = in(), ra[i] = in();
	_rep(i,1,m) lb[i] = in(), rb[i] = in();
	f[0][0][0] = 1; f[0][0][1] = p - 1;
	_rep(i,0,n) _rep(j,0,m) {
		_rep(k,-v,v) {
			int cur = (f[i][j][k] = (f[i][j][k] + f[i][j][k - 1]) % p);
			if(!cur) continue;
			if(k <= 0 && i < n) {
				f[i + 1][j][k + la[i + 1]] = (f[i + 1][j][k + la[i + 1]] + cur) % p;
				f[i + 1][j][k + ra[i + 1] + 1] = (f[i + 1][j][k + ra[i + 1] + 1] - cur + p) % p;
			} else if(j < m) {
				f[i][j + 1][k - rb[j + 1]] = (f[i][j + 1][k - rb[j + 1]] + cur) % p;
				f[i][j + 1][k - lb[j + 1] + 1] = (f[i][j + 1][k - lb[j + 1] + 1] - cur + p) % p;
			}
		}
	}
	_rep(i,1,n) _rep(j,1,m) printf("%d%c", f[i][j][0], " \n"[j == m]);
	return 0;
}

/* 
a list of keywords
clear empty push_back pop_back push pop top front back
emplace_back emplace push_front pop_front insert erase
find count set reset bitset map vector string multiset
first second iterator prev next deque multimap reverse
sort begin end list modify query init check calc prime
putchar getchar puts scanf printf max min swap replace
make_pair make_tuple numeric_limits auto function null
*/

详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 6332kb

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: 1432ms
memory: 998156kb

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:

411 79401 9145270 673005095 180581065 984223118 586589234 293043270 404363796 865361724 665487988 118838806 926189944 226338288 521479857 808644951 786041288 340769021 177100 21 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 ...

result:

wrong answer 249527th numbers differ - expected: '953584739', found: '997313833'