QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#772564#2506. 数列Link_Cut_Y#100 ✓28ms32936kbC++143.3kb2024-11-22 20:20:182024-11-22 20:20:18

Judging History

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

  • [2024-11-22 20:20:18]
  • 评测
  • 测评结果:100
  • 用时:28ms
  • 内存:32936kb
  • [2024-11-22 20:20:18]
  • 提交

answer

#include <unordered_map>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>
#include <vector>
#include <bitset>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define int long long
#define rep(i, a, b) for (int i = (a); i <= (b); i ++ )
#define rop(i, a, b) for (int i = (a); i < (b); i ++ )
#define dep(i, a, b) for (int i = (a); i >= (b); i -- )
#define dop(i, a, b) for (int i = (a); i > (b); i -- )

#define Darr(a, L, R) cerr << #a "[" << L << " ~ " << R << "] = "; rep(x, L, R) cerr << a[x] << " "; cerr << '\n';
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define D(x) (cerr << #x << " = " << x << '\n')
#define vit vector<int>::iterator
#define all(x) x.begin(), x.end()
#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)
#define chkmin(a, b) (a = min(a, b))
#define chkmax(a, b) (a = max(a, b))
#define sit set<int>::iterator
#define lowbit(x) (x & -x)
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pi acos(-1)
#define gc getchar
#define pc putchar
#define db double
#define y second
#define x first

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef pair<db, db> PDD;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
const int mod = 998244353;
const int eps = 1e-9;

int T = 1;
void print(int x) { dep(i, 20, 0) pc(((x >> i) & 1) ? '1' : '0'); }
int qpow(int a, int b = mod - 2, int s = 1) { for (; b; b >>= 1, a = 1ll * a * a % mod) if (b & 1) s = 1ll * s * a % mod; return s; }
namespace IO {
	void read() { return; }
	void write(char ch) { pc(ch); return; }
	void write() { return; }
	template <typename T> void read(T &x) { x = 0; T w = 0; char ch = gc(); while (ch < '0' || ch > '9') w |= (ch == '-'), ch = gc(); while ('0' <= ch && ch <= '9') x = x * 10 + (ch ^ 48), ch = gc(); x = w ? -x : x; }
	template <typename T> void print(T x) { if (!x) return; print<T>(x / 10), pc((x % 10) ^ '0'); }
	template <typename T> void write(T x) { if (x > 0) print<T>(x); else if (x < 0) pc('-'), print<T>(-x); else pc('0'); }
	template <typename T> void write(T x, char en) { write<T>(x), pc(en); }
	template <typename T, typename ...T2> void read(T &s, T2 &...oth) { read(s); read(oth...); return; }
}; using namespace IO;

const int N = 33, M = 110;
int f[N][M][N][N], n, m, K, v[M], fac[N], inv[N], pw[M][M];
void sub() {
	read(n, m, K);
	rep(i, 0, m) read(v[i]);
	fac[0] = inv[0] = 1;
	rep(i, 1, n) fac[i] = fac[i - 1] * i % mod;
	inv[n] = qpow(fac[n]); dep(i, n - 1, 1) inv[i] = inv[i + 1] * (i + 1) % mod;
	rep(i, 0, m) rep(j, 0, n) pw[i][j] = qpow(v[i], j);
	auto C = [&](int n, int m) -> int {
		if (m > n) return 0ll;
		return fac[n] * inv[m] % mod * inv[n - m] % mod;
	};
	rep(i, 0, n) f[i][0][i][0] = C(n, i) * pw[0][i] % mod;
	rep(i, 0, n) rep(j, 0, m + 6) rep(k, 0, n) rep(l, 0, K) {
		if (!f[i][j][k][l]) continue;
		if (j < m) {
			rep(w, 0, n - i) 
				(f[i + w][j + 1][k / 2 + w][l + (k % 2)] += f[i][j][k][l] * C(n - i, w) % mod * pw[j + 1][w] % mod) %= mod;
		} else (f[i][j + 1][k / 2][l + (k % 2)] += f[i][j][k][l]) %= mod;
	} int ans = 0;
	rep(i, 0, K) ans = (ans + f[n][m + 6][0][i]) % mod;
	printf("%lld\n", ans); 
}
signed main() {
	while (T -- ) sub();
	return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息


Pretests


Final Tests

Test #1:

score: 5
Accepted
time: 0ms
memory: 12016kb

input:

8 9 1
499488183 118995914 332316574 399234563 246850128 338768262 489466833 673193710 723933572 12759125

output:

789420212

result:

ok single line: '789420212'

Test #2:

score: 5
Accepted
time: 1ms
memory: 12220kb

input:

8 9 3
215521602 492908007 261206435 521145497 259750366 553629902 997991039 523071946 767416953 56767036

output:

450775894

result:

ok single line: '450775894'

Test #3:

score: 5
Accepted
time: 2ms
memory: 12040kb

input:

8 9 5
396559700 356016879 796231055 117198018 986043211 5573279 915325714 896890982 238440937 772820521

output:

34463958

result:

ok single line: '34463958'

Test #4:

score: 5
Accepted
time: 0ms
memory: 12108kb

input:

8 9 8
823551883 246279514 512316795 50015811 596048859 634297559 357816173 172030638 277258510 920803140

output:

650836255

result:

ok single line: '650836255'

Test #5:

score: 5
Accepted
time: 3ms
memory: 32620kb

input:

30 7 5
277343567 231557726 518417466 839831772 308153685 661255375 10400942 137452650

output:

570273281

result:

ok single line: '570273281'

Test #6:

score: 5
Accepted
time: 5ms
memory: 30600kb

input:

30 7 6
769481383 218933928 397917786 715817994 28458205 1741468 432666671 767453624

output:

802897416

result:

ok single line: '802897416'

Test #7:

score: 5
Accepted
time: 5ms
memory: 30596kb

input:

30 7 9
560097542 225678652 985380091 657360686 588960965 286023927 39451645 813153395

output:

200784526

result:

ok single line: '200784526'

Test #8:

score: 5
Accepted
time: 3ms
memory: 32728kb

input:

30 12 7
233649570 882345965 363522936 697518226 276565878 305171861 862016201 694650802 295202855 895115917 87982489 198145962 118457524

output:

191413880

result:

ok single line: '191413880'

Test #9:

score: 5
Accepted
time: 0ms
memory: 32484kb

input:

30 12 8
280972635 121394003 96961086 311593799 16824904 872035232 806270513 706873478 838387709 911762507 518375946 363189973 93846934

output:

878193241

result:

ok single line: '878193241'

Test #10:

score: 5
Accepted
time: 3ms
memory: 32676kb

input:

30 12 14
33118764 570808334 277911327 206225040 739764940 873120222 787166401 297143172 542645907 209959496 558572198 749568456 492469905

output:

8638776

result:

ok single line: '8638776'

Test #11:

score: 5
Accepted
time: 6ms
memory: 32824kb

input:

30 100 1
280989359 685610909 652483091 218262426 612187297 933993851 128465889 118119862 758459128 482869427 840417548 996214463 836110953 8956015 894945622 619560556 219818505 29451496 358272495 696206257 230342287 851588985 859573270 833968093 763204877 853785448 282969832 273841812 923102044 4584...

output:

918455864

result:

ok single line: '918455864'

Test #12:

score: 5
Accepted
time: 7ms
memory: 31920kb

input:

30 100 1
238187011 269812145 373797704 493559311 525459197 494840062 127348462 781447685 540053429 448451906 15397875 202443100 38732140 40023578 278484005 462334159 562679988 736926803 282626752 723781472 662277299 358863810 27984540 832197799 962665975 699557436 986649610 436908753 320494341 95769...

output:

524381135

result:

ok single line: '524381135'

Test #13:

score: 5
Accepted
time: 6ms
memory: 32716kb

input:

30 100 1
624756242 578099224 322063599 955163372 527409783 886224870 196768173 678404094 71254380 400463809 462704961 522697398 174568824 839996207 181664607 564129436 324853491 954240664 279841814 134343701 734819121 855324702 517923195 647253253 321867400 801360468 25886504 866237487 301424065 286...

output:

483241545

result:

ok single line: '483241545'

Test #14:

score: 5
Accepted
time: 1ms
memory: 8556kb

input:

5 50 2
254286688 725442098 427960764 796779405 986706963 905854411 818897107 964334286 867743930 583810772 621078041 875275863 94943935 993613474 699229610 139437533 160785883 74877034 8820884 154629232 776225564 385632450 792900606 570001565 857615216 758514611 34346579 426872784 329305393 59552423...

output:

816583992

result:

ok single line: '816583992'

Test #15:

score: 5
Accepted
time: 1ms
memory: 10124kb

input:

5 50 3
398838269 62831191 767680179 548733975 555826543 359315797 126732814 236236917 736299966 477904769 853166426 287461631 463135258 178798437 997403650 87158184 572906600 697966474 960138109 242347816 879956491 777432793 390570007 708647774 714109560 612901589 377307686 585724634 560144176 50107...

output:

937159818

result:

ok single line: '937159818'

Test #16:

score: 5
Accepted
time: 0ms
memory: 18600kb

input:

15 100 8
537276628 100186052 185892981 934916070 567805882 918515644 431750302 796355931 218646822 867528879 340335349 895838502 324783806 28262471 36921137 16069248 30657555 649491332 119673208 552651140 623025591 114876021 403198375 59453768 518635907 617927870 217741861 573018213 950960313 720041...

output:

272087880

result:

ok single line: '272087880'

Test #17:

score: 5
Accepted
time: 8ms
memory: 31032kb

input:

30 30 15
60466183 610467381 171141086 693914857 963904829 564659588 530320949 440079007 365069705 829699120 283564411 328402092 300168872 613261423 746486046 10288211 360128573 745361137 454560349 807372883 536663856 136356261 883801886 164316038 21520306 943453842 666136933 543391844 857298855 3384...

output:

72174927

result:

ok single line: '72174927'

Test #18:

score: 5
Accepted
time: 8ms
memory: 32616kb

input:

30 30 27
791704008 141733617 624846593 851709929 992710617 212811783 633109877 793261502 936354310 396919562 836912348 231815656 963288997 740034788 423011666 759150033 384434935 683576701 853721112 420009380 582576185 749031968 9524373 451203892 109835437 775487403 621839989 303055045 36699775 3463...

output:

253611021

result:

ok single line: '253611021'

Test #19:

score: 5
Accepted
time: 28ms
memory: 32808kb

input:

30 100 16
875698537 331313447 201148316 859357152 75556427 84009302 29165462 183164679 801095477 362574916 174220357 904633392 840544725 26263814 209015337 148424354 181158359 130045322 130726397 756114144 893268484 890267565 401189740 163241681 937879687 734913073 137564816 583877304 334189462 8327...

output:

221099086

result:

ok single line: '221099086'

Test #20:

score: 5
Accepted
time: 28ms
memory: 32936kb

input:

30 100 21
316605536 504649194 334973924 478542137 897005201 967219463 982199815 294027518 578515247 444956501 169932813 517443072 608712080 853574514 517686368 318771389 413578320 648466530 224572747 536246850 615211381 271710227 740813454 795114103 726388592 324201075 793546883 933899825 539137621 ...

output:

483943039

result:

ok single line: '483943039'

Extra Test:

score: 0
Extra Test Passed