QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#154658#6614. Cards of Magicdo_while_trueAC ✓16ms26192kbC++203.3kb2023-08-31 20:40:592023-08-31 20:40:59

Judging History

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

  • [2023-08-31 20:40:59]
  • 评测
  • 测评结果:AC
  • 用时:16ms
  • 内存:26192kb
  • [2023-08-31 20:40:59]
  • 提交

answer

#include<cstdio>
#include<vector>
#include<queue>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<ctime>
#include<random>
#include<assert.h>
#include<functional>
#define pb emplace_back
#define mp make_pair
#define fi first
#define se second
#define dbg(x) cerr<<"In Line "<< __LINE__<<" the "<<#x<<" = "<<x<<'\n'
#define dpi(x,y) cerr<<"In Line "<<__LINE__<<" the "<<#x<<" = "<<x<<" ; "<<"the "<<#y<<" = "<<y<<'\n'
#define DE(fmt,...) fprintf(stderr, "Line %d : " fmt "\n",__LINE__,##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int>pii;
typedef pair<ll,int>pli;
typedef pair<ll,ll>pll;
typedef pair<int,ll>pil;
typedef vector<int>vi;
typedef vector<ll>vll;
typedef vector<pii>vpii;
typedef vector<pll>vpll;
template<typename T>T cmax(T &x, T y){return x=x>y?x:y;}
template<typename T>T cmin(T &x, T y){return x=x<y?x:y;}
template<typename T>
T &read(T &r){
	r=0;bool w=0;char ch=getchar();
	while(ch<'0'||ch>'9')w=ch=='-'?1:0,ch=getchar();
	while(ch>='0'&&ch<='9')r=r*10+(ch^48),ch=getchar();
	return r=w?-r:r;
}
template<typename T1,typename... T2>
void read(T1 &x,T2& ...y){read(x);read(y...);}
const int mod=998244353;
inline void cadd(int &x,int y){x=(x+y>=mod)?(x+y-mod):(x+y);}
inline void cdel(int &x,int y){x=(x-y<0)?(x-y+mod):(x-y);}
inline int add(int x,int y){return (x+y>=mod)?(x+y-mod):(x+y);}
inline int del(int x,int y){return (x-y<0)?(x-y+mod):(x-y);}
int qpow(int x,int y){
	int s=1;
	while(y){
		if(y&1)s=1ll*s*x%mod;
		x=1ll*x*x%mod;
		y>>=1;
	}
	return s;
}
const int N=200010;
const int i3=332748118;
int f[N][2][3];//摸了n张牌, 0/>=1张fire, 0/1/>=2张copy
int g[N][2][3];//water打过, 怪物血量为k, 用了0/>=1张fire, 手里0张/手里1张/打出一张copy
int dfs(int k,int f,int c){
	if(k<=0)return 0;
	if(c==1&&k<=2)return 0;
	if(c==1&&f==1&&k<=4)return 0;
	if(~g[k][f][c])return g[k][f][c];
	int &now=g[k][f][c];now=1;
	//water
	cadd(now,1ll*i3*dfs(k-1,f,c)%mod);
	//fire
	if(c==1)cadd(now,1ll*i3*dfs(k-7,1,2)%mod);
	else cadd(now,1ll*i3*dfs(k-3,1,c)%mod);
	//copy
	if(c==0){
		if(f)cadd(now,1ll*i3*dfs(k-4,1,2)%mod);
		else cadd(now,1ll*i3*dfs(k,0,1)%mod);
	}
	return now;
}
int n;
signed main(){
	#ifdef do_while_true
//		assert(freopen("data.in","r",stdin));
//		assert(freopen("data.out","w",stdout));
	#endif
	read(n);
	f[0][0][0]=1;
	for(int i=0;i<=(n+1)/2;i++)
		for(int j=0;j<=1;j++)
			for(int k=0;k<=2;k++){
				cadd(f[i+1][min(j+1,1)][k],1ll*i3*f[i][j][k]%mod);
				cadd(f[i+1][j][min(k+1,2)],1ll*i3*f[i][j][k]%mod);
			}
	int ans=0;
	memset(g,-1,sizeof(g));
	for(int i=0;i<=(n-1)/2;i++){//在i+1张牌抽到water
		cadd(ans,1ll*i3*f[i][0][0]%mod*(i+1+dfs(n,0,0))%mod);
		cadd(ans,1ll*i3*f[i][0][1]%mod*(i+1+dfs(n,0,1))%mod);
		cadd(ans,1ll*i3*f[i][0][2]%mod*(i+1)%mod);
		
		cadd(ans,1ll*i3*f[i][1][0]%mod*(i+1+dfs(n-3*i,1,0))%mod);
		cadd(ans,1ll*i3*f[i][1][1]%mod*(i+1+dfs(n-3*(i-1)-4,1,2))%mod);
		cadd(ans,1ll*i3*f[i][1][2]%mod*(i+1)%mod);
	}
	for(int i=0;i<3;i++){
		cadd(ans,1ll*f[(n+1)/2][0][i]*((n+1)/2+3ll*499122177%mod)%mod);
		cadd(ans,1ll*f[(n+1)/2][1][i]*((n+1)/2)%mod);
	}
	cout<<ans<<'\n';
    #ifdef do_while_true
//		cerr<<'\n'<<"Time:"<<1.0*clock()/CLOCKS_PER_SEC*1000<<" ms"<<'\n';
	#endif
	return 0;
}

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

详细

Test #1:

score: 100
Accepted
time: 2ms
memory: 8352kb

input:

1

output:

831870296

result:

ok 1 number(s): "831870296"

Test #2:

score: 0
Accepted
time: 3ms
memory: 8992kb

input:

5

output:

835978299

result:

ok 1 number(s): "835978299"

Test #3:

score: 0
Accepted
time: 3ms
memory: 9476kb

input:

2

output:

277290100

result:

ok 1 number(s): "277290100"

Test #4:

score: 0
Accepted
time: 3ms
memory: 9000kb

input:

3

output:

979758349

result:

ok 1 number(s): "979758349"

Test #5:

score: 0
Accepted
time: 2ms
memory: 9904kb

input:

4

output:

141726053

result:

ok 1 number(s): "141726053"

Test #6:

score: 0
Accepted
time: 0ms
memory: 8916kb

input:

6

output:

393683476

result:

ok 1 number(s): "393683476"

Test #7:

score: 0
Accepted
time: 1ms
memory: 9880kb

input:

7

output:

206541188

result:

ok 1 number(s): "206541188"

Test #8:

score: 0
Accepted
time: 1ms
memory: 8232kb

input:

8

output:

993603837

result:

ok 1 number(s): "993603837"

Test #9:

score: 0
Accepted
time: 2ms
memory: 10064kb

input:

9

output:

709289564

result:

ok 1 number(s): "709289564"

Test #10:

score: 0
Accepted
time: 1ms
memory: 9656kb

input:

10

output:

445988648

result:

ok 1 number(s): "445988648"

Test #11:

score: 0
Accepted
time: 3ms
memory: 9476kb

input:

11

output:

622925737

result:

ok 1 number(s): "622925737"

Test #12:

score: 0
Accepted
time: 0ms
memory: 9508kb

input:

12

output:

363599458

result:

ok 1 number(s): "363599458"

Test #13:

score: 0
Accepted
time: 2ms
memory: 8260kb

input:

13

output:

338621482

result:

ok 1 number(s): "338621482"

Test #14:

score: 0
Accepted
time: 2ms
memory: 9964kb

input:

14

output:

397966377

result:

ok 1 number(s): "397966377"

Test #15:

score: 0
Accepted
time: 1ms
memory: 9176kb

input:

15

output:

911767168

result:

ok 1 number(s): "911767168"

Test #16:

score: 0
Accepted
time: 2ms
memory: 9424kb

input:

16

output:

664727836

result:

ok 1 number(s): "664727836"

Test #17:

score: 0
Accepted
time: 2ms
memory: 9852kb

input:

17

output:

868443132

result:

ok 1 number(s): "868443132"

Test #18:

score: 0
Accepted
time: 2ms
memory: 9176kb

input:

18

output:

796806191

result:

ok 1 number(s): "796806191"

Test #19:

score: 0
Accepted
time: 2ms
memory: 8656kb

input:

19

output:

36284050

result:

ok 1 number(s): "36284050"

Test #20:

score: 0
Accepted
time: 1ms
memory: 8740kb

input:

20

output:

78593146

result:

ok 1 number(s): "78593146"

Test #21:

score: 0
Accepted
time: 0ms
memory: 8500kb

input:

21

output:

113581844

result:

ok 1 number(s): "113581844"

Test #22:

score: 0
Accepted
time: 0ms
memory: 8552kb

input:

22

output:

652629455

result:

ok 1 number(s): "652629455"

Test #23:

score: 0
Accepted
time: 2ms
memory: 8440kb

input:

23

output:

26889816

result:

ok 1 number(s): "26889816"

Test #24:

score: 0
Accepted
time: 0ms
memory: 8216kb

input:

24

output:

973075191

result:

ok 1 number(s): "973075191"

Test #25:

score: 0
Accepted
time: 1ms
memory: 9548kb

input:

25

output:

606233734

result:

ok 1 number(s): "606233734"

Test #26:

score: 0
Accepted
time: 2ms
memory: 9168kb

input:

26

output:

251968195

result:

ok 1 number(s): "251968195"

Test #27:

score: 0
Accepted
time: 2ms
memory: 8456kb

input:

27

output:

160663854

result:

ok 1 number(s): "160663854"

Test #28:

score: 0
Accepted
time: 2ms
memory: 8996kb

input:

28

output:

644704526

result:

ok 1 number(s): "644704526"

Test #29:

score: 0
Accepted
time: 2ms
memory: 9672kb

input:

29

output:

880366020

result:

ok 1 number(s): "880366020"

Test #30:

score: 0
Accepted
time: 0ms
memory: 8848kb

input:

30

output:

563180515

result:

ok 1 number(s): "563180515"

Test #31:

score: 0
Accepted
time: 2ms
memory: 9572kb

input:

31

output:

488966461

result:

ok 1 number(s): "488966461"

Test #32:

score: 0
Accepted
time: 2ms
memory: 9232kb

input:

32

output:

73977159

result:

ok 1 number(s): "73977159"

Test #33:

score: 0
Accepted
time: 2ms
memory: 10008kb

input:

33

output:

478257304

result:

ok 1 number(s): "478257304"

Test #34:

score: 0
Accepted
time: 2ms
memory: 9612kb

input:

34

output:

840731886

result:

ok 1 number(s): "840731886"

Test #35:

score: 0
Accepted
time: 0ms
memory: 9296kb

input:

35

output:

116945142

result:

ok 1 number(s): "116945142"

Test #36:

score: 0
Accepted
time: 2ms
memory: 9868kb

input:

36

output:

965694497

result:

ok 1 number(s): "965694497"

Test #37:

score: 0
Accepted
time: 3ms
memory: 9412kb

input:

37

output:

167489378

result:

ok 1 number(s): "167489378"

Test #38:

score: 0
Accepted
time: 2ms
memory: 8084kb

input:

38

output:

100691350

result:

ok 1 number(s): "100691350"

Test #39:

score: 0
Accepted
time: 2ms
memory: 8256kb

input:

39

output:

160240217

result:

ok 1 number(s): "160240217"

Test #40:

score: 0
Accepted
time: 1ms
memory: 9020kb

input:

40

output:

151280240

result:

ok 1 number(s): "151280240"

Test #41:

score: 0
Accepted
time: 1ms
memory: 9504kb

input:

41

output:

521028725

result:

ok 1 number(s): "521028725"

Test #42:

score: 0
Accepted
time: 2ms
memory: 9344kb

input:

42

output:

691288796

result:

ok 1 number(s): "691288796"

Test #43:

score: 0
Accepted
time: 3ms
memory: 9460kb

input:

43

output:

695894234

result:

ok 1 number(s): "695894234"

Test #44:

score: 0
Accepted
time: 2ms
memory: 9984kb

input:

44

output:

216804850

result:

ok 1 number(s): "216804850"

Test #45:

score: 0
Accepted
time: 0ms
memory: 8220kb

input:

45

output:

39241895

result:

ok 1 number(s): "39241895"

Test #46:

score: 0
Accepted
time: 0ms
memory: 8832kb

input:

46

output:

471395300

result:

ok 1 number(s): "471395300"

Test #47:

score: 0
Accepted
time: 2ms
memory: 8260kb

input:

47

output:

957503329

result:

ok 1 number(s): "957503329"

Test #48:

score: 0
Accepted
time: 0ms
memory: 9848kb

input:

48

output:

658978397

result:

ok 1 number(s): "658978397"

Test #49:

score: 0
Accepted
time: 2ms
memory: 9848kb

input:

49

output:

99569804

result:

ok 1 number(s): "99569804"

Test #50:

score: 0
Accepted
time: 2ms
memory: 8272kb

input:

50

output:

169299123

result:

ok 1 number(s): "169299123"

Test #51:

score: 0
Accepted
time: 1ms
memory: 9380kb

input:

60

output:

977734538

result:

ok 1 number(s): "977734538"

Test #52:

score: 0
Accepted
time: 1ms
memory: 9368kb

input:

70

output:

970937590

result:

ok 1 number(s): "970937590"

Test #53:

score: 0
Accepted
time: 0ms
memory: 9768kb

input:

80

output:

68069121

result:

ok 1 number(s): "68069121"

Test #54:

score: 0
Accepted
time: 2ms
memory: 8676kb

input:

90

output:

822014036

result:

ok 1 number(s): "822014036"

Test #55:

score: 0
Accepted
time: 2ms
memory: 9980kb

input:

100

output:

984213121

result:

ok 1 number(s): "984213121"

Test #56:

score: 0
Accepted
time: 1ms
memory: 9444kb

input:

200

output:

490385842

result:

ok 1 number(s): "490385842"

Test #57:

score: 0
Accepted
time: 2ms
memory: 9840kb

input:

300

output:

105448551

result:

ok 1 number(s): "105448551"

Test #58:

score: 0
Accepted
time: 1ms
memory: 8312kb

input:

400

output:

276757989

result:

ok 1 number(s): "276757989"

Test #59:

score: 0
Accepted
time: 2ms
memory: 9740kb

input:

500

output:

897091044

result:

ok 1 number(s): "897091044"

Test #60:

score: 0
Accepted
time: 2ms
memory: 8388kb

input:

600

output:

895458430

result:

ok 1 number(s): "895458430"

Test #61:

score: 0
Accepted
time: 3ms
memory: 9184kb

input:

700

output:

225501166

result:

ok 1 number(s): "225501166"

Test #62:

score: 0
Accepted
time: 2ms
memory: 8280kb

input:

800

output:

749404996

result:

ok 1 number(s): "749404996"

Test #63:

score: 0
Accepted
time: 2ms
memory: 8624kb

input:

900

output:

132833283

result:

ok 1 number(s): "132833283"

Test #64:

score: 0
Accepted
time: 2ms
memory: 10068kb

input:

1000

output:

152309562

result:

ok 1 number(s): "152309562"

Test #65:

score: 0
Accepted
time: 0ms
memory: 8560kb

input:

2000

output:

479802764

result:

ok 1 number(s): "479802764"

Test #66:

score: 0
Accepted
time: 3ms
memory: 10196kb

input:

3000

output:

652207059

result:

ok 1 number(s): "652207059"

Test #67:

score: 0
Accepted
time: 3ms
memory: 8812kb

input:

4000

output:

734931577

result:

ok 1 number(s): "734931577"

Test #68:

score: 0
Accepted
time: 3ms
memory: 9620kb

input:

5000

output:

825472551

result:

ok 1 number(s): "825472551"

Test #69:

score: 0
Accepted
time: 3ms
memory: 10204kb

input:

6000

output:

330247572

result:

ok 1 number(s): "330247572"

Test #70:

score: 0
Accepted
time: 0ms
memory: 9440kb

input:

7000

output:

166161267

result:

ok 1 number(s): "166161267"

Test #71:

score: 0
Accepted
time: 1ms
memory: 10252kb

input:

8000

output:

500098577

result:

ok 1 number(s): "500098577"

Test #72:

score: 0
Accepted
time: 3ms
memory: 10048kb

input:

9000

output:

15226803

result:

ok 1 number(s): "15226803"

Test #73:

score: 0
Accepted
time: 3ms
memory: 10376kb

input:

10000

output:

561328420

result:

ok 1 number(s): "561328420"

Test #74:

score: 0
Accepted
time: 1ms
memory: 11260kb

input:

20000

output:

805231759

result:

ok 1 number(s): "805231759"

Test #75:

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

input:

30000

output:

688026059

result:

ok 1 number(s): "688026059"

Test #76:

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

input:

40000

output:

486519283

result:

ok 1 number(s): "486519283"

Test #77:

score: 0
Accepted
time: 1ms
memory: 12664kb

input:

50000

output:

575414887

result:

ok 1 number(s): "575414887"

Test #78:

score: 0
Accepted
time: 3ms
memory: 13516kb

input:

60000

output:

837347269

result:

ok 1 number(s): "837347269"

Test #79:

score: 0
Accepted
time: 1ms
memory: 14832kb

input:

70000

output:

889708031

result:

ok 1 number(s): "889708031"

Test #80:

score: 0
Accepted
time: 3ms
memory: 15412kb

input:

80000

output:

500541937

result:

ok 1 number(s): "500541937"

Test #81:

score: 0
Accepted
time: 3ms
memory: 16244kb

input:

90000

output:

62490272

result:

ok 1 number(s): "62490272"

Test #82:

score: 0
Accepted
time: 4ms
memory: 17888kb

input:

100000

output:

975871004

result:

ok 1 number(s): "975871004"

Test #83:

score: 0
Accepted
time: 9ms
memory: 26028kb

input:

200000

output:

621238861

result:

ok 1 number(s): "621238861"

Test #84:

score: 0
Accepted
time: 0ms
memory: 9660kb

input:

244

output:

647546249

result:

ok 1 number(s): "647546249"

Test #85:

score: 0
Accepted
time: 2ms
memory: 8208kb

input:

443

output:

504698464

result:

ok 1 number(s): "504698464"

Test #86:

score: 0
Accepted
time: 1ms
memory: 8476kb

input:

176

output:

158374104

result:

ok 1 number(s): "158374104"

Test #87:

score: 0
Accepted
time: 0ms
memory: 9820kb

input:

9292

output:

76268439

result:

ok 1 number(s): "76268439"

Test #88:

score: 0
Accepted
time: 3ms
memory: 10800kb

input:

11168

output:

434000771

result:

ok 1 number(s): "434000771"

Test #89:

score: 0
Accepted
time: 1ms
memory: 9496kb

input:

7409

output:

972518375

result:

ok 1 number(s): "972518375"

Test #90:

score: 0
Accepted
time: 3ms
memory: 8860kb

input:

4139

output:

118021377

result:

ok 1 number(s): "118021377"

Test #91:

score: 0
Accepted
time: 3ms
memory: 9628kb

input:

2360

output:

557425603

result:

ok 1 number(s): "557425603"

Test #92:

score: 0
Accepted
time: 2ms
memory: 9176kb

input:

921

output:

763066923

result:

ok 1 number(s): "763066923"

Test #93:

score: 0
Accepted
time: 3ms
memory: 10152kb

input:

6370

output:

119414004

result:

ok 1 number(s): "119414004"

Test #94:

score: 0
Accepted
time: 1ms
memory: 10184kb

input:

16672

output:

225059960

result:

ok 1 number(s): "225059960"

Test #95:

score: 0
Accepted
time: 0ms
memory: 12784kb

input:

42169

output:

797539311

result:

ok 1 number(s): "797539311"

Test #96:

score: 0
Accepted
time: 4ms
memory: 16016kb

input:

87826

output:

45005343

result:

ok 1 number(s): "45005343"

Test #97:

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

input:

33549

output:

976562341

result:

ok 1 number(s): "976562341"

Test #98:

score: 0
Accepted
time: 9ms
memory: 15544kb

input:

83250

output:

979484328

result:

ok 1 number(s): "979484328"

Test #99:

score: 0
Accepted
time: 9ms
memory: 21112kb

input:

141890

output:

794692128

result:

ok 1 number(s): "794692128"

Test #100:

score: 0
Accepted
time: 9ms
memory: 15164kb

input:

77620

output:

7849962

result:

ok 1 number(s): "7849962"

Test #101:

score: 0
Accepted
time: 4ms
memory: 14728kb

input:

69995

output:

364205390

result:

ok 1 number(s): "364205390"

Test #102:

score: 0
Accepted
time: 12ms
memory: 22552kb

input:

162241

output:

240880724

result:

ok 1 number(s): "240880724"

Test #103:

score: 0
Accepted
time: 7ms
memory: 24636kb

input:

183966

output:

167125223

result:

ok 1 number(s): "167125223"

Test #104:

score: 0
Accepted
time: 13ms
memory: 25624kb

input:

195541

output:

762776485

result:

ok 1 number(s): "762776485"

Test #105:

score: 0
Accepted
time: 9ms
memory: 20272kb

input:

136901

output:

837991108

result:

ok 1 number(s): "837991108"

Test #106:

score: 0
Accepted
time: 9ms
memory: 25680kb

input:

194613

output:

384410784

result:

ok 1 number(s): "384410784"

Test #107:

score: 0
Accepted
time: 7ms
memory: 25552kb

input:

194632

output:

838353104

result:

ok 1 number(s): "838353104"

Test #108:

score: 0
Accepted
time: 11ms
memory: 24080kb

input:

177132

output:

420003183

result:

ok 1 number(s): "420003183"

Test #109:

score: 0
Accepted
time: 11ms
memory: 25060kb

input:

189159

output:

192759818

result:

ok 1 number(s): "192759818"

Test #110:

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

input:

192552

output:

377372327

result:

ok 1 number(s): "377372327"

Test #111:

score: 0
Accepted
time: 8ms
memory: 24376kb

input:

181566

output:

991185836

result:

ok 1 number(s): "991185836"

Test #112:

score: 0
Accepted
time: 7ms
memory: 26128kb

input:

199679

output:

477499113

result:

ok 1 number(s): "477499113"

Test #113:

score: 0
Accepted
time: 12ms
memory: 26008kb

input:

199352

output:

823328344

result:

ok 1 number(s): "823328344"

Test #114:

score: 0
Accepted
time: 16ms
memory: 26084kb

input:

199408

output:

924981866

result:

ok 1 number(s): "924981866"

Test #115:

score: 0
Accepted
time: 13ms
memory: 25892kb

input:

198741

output:

554240349

result:

ok 1 number(s): "554240349"

Test #116:

score: 0
Accepted
time: 15ms
memory: 26192kb

input:

199995

output:

401387038

result:

ok 1 number(s): "401387038"