QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#67256#5099. 朝圣道Graphcity4 275ms14356kbC++20788b2022-12-10 11:12:042022-12-10 11:12:22

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2022-12-10 11:12:22]
  • 评测
  • 测评结果:4
  • 用时:275ms
  • 内存:14356kb
  • [2022-12-10 11:12:04]
  • 提交

answer

#include<bits/stdc++.h>
#include "pilgrimage.h"
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rof(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
const int Maxn=1e3;

int inv2,inv4,Mod,f[Maxn+5][Maxn*2+5];

inline int exgcd(int a,int b,int &x,int &y)
{
	if(!b) {x=1,y=0; return a;}
	int res=exgcd(b,a%b,y,x);
	y=y-a/b*x; return res;
}
inline int Inv(int x)
{
	int hzh,rub; exgcd(x,Mod,hzh,rub);
	return (hzh%Mod+Mod)%Mod;
}

void init(int o, int p)
{
	Mod=p,inv2=Inv(2),inv4=Inv(4);
	f[0][Maxn]=1;
	For(i,1,Maxn) For(j,Maxn-i,Maxn+i)
		f[i][j]=(1ll*f[i-1][j-1]*inv4%Mod+1ll*f[i-1][j]*inv2%Mod+1ll*f[i-1][j+1]*inv4%Mod)%Mod;
}

int ask(long long n)
{
	int res=0;
	For(i,Maxn-n,Maxn+n) res=(res+1ll*f[n][i]*abs(i-Maxn)%Mod)%Mod;
	return res;
}

詳細信息

Subtask #1:

score: 4
Accepted

Test #1:

score: 4
Accepted
time: 270ms
memory: 14356kb

input:

1 910276 554767
6
10
7
4
10
12
9
3
3
5
7
10
5
6
1
6
3
9
6
8
12
11
8
2
12
5
9
3
8
2
12
11
2
3
4
9
2
5
5
11
6
4
8
11
3
9
2
2
8
9
2
8
9
6
2
9
2
10
10
7
5
6
4
4
11
12
8
8
2
2
4
3
3
5
6
6
8
11
6
9
9
3
4
1
2
2
6
9
9
2
3
2
12
6
1
7
2
4
12
11
4
7
6
3
9
4
6
5
3
3
12
6
2
1
1
7
2
6
5
9
11
6
3
4
11
1
2
4
5
4
10...

output:

5419
364275
514407
329394
364275
229662
53120
520095
520095
509260
514407
364275
509260
5419
277384
5419
520095
53120
5419
115262
229662
243797
115262
416076
229662
509260
53120
520095
115262
416076
229662
243797
416076
520095
329394
53120
416076
509260
509260
243797
5419
329394
115262
243797
520095...

result:

ok 910276 numbers

Test #2:

score: 0
Accepted
time: 275ms
memory: 14304kb

input:

1 972231 293475
7
1
9
6
5
1
11
5
5
12
2
2
7
3
4
10
10
3
2
10
7
1
10
9
1
3
5
6
7
2
7
4
1
10
1
9
3
10
10
2
6
11
4
10
12
8
5
2
12
4
9
12
7
2
12
4
3
1
2
9
12
1
4
5
6
12
6
5
9
2
5
12
3
4
6
12
12
2
1
6
4
12
10
5
12
7
9
8
3
8
10
5
3
6
12
7
7
10
7
10
8
7
7
2
2
4
8
6
10
8
11
6
11
10
3
9
5
2
5
1
10
2
11
4
4
3...

output:

117936
146738
29445
289464
209790
146738
240513
209790
209790
158067
220107
220107
117936
201765
284305
145210
145210
201765
220107
145210
117936
146738
145210
29445
146738
201765
209790
289464
117936
220107
117936
284305
146738
145210
146738
29445
201765
145210
145210
220107
289464
240513
284305
14...

result:

ok 972231 numbers

Subtask #2:

score: 0
Runtime Error

Dependency #1:

100%
Accepted

Test #3:

score: 0
Runtime Error

input:

2 957481 386233
816
1256
2812
1370
1469
1439
33
929
1437
2680
1001
1846
1936
1161
1823
1417
2823
1753
2434
577
1671
676
174
2401
1762
123
785
604
1650
117
2344
1365
221
1096
1087
1057
457
2254
647
1827
266
1599
1445
83
2685
1372
1795
2595
1909
2605
1608
2656
1114
581
725
725
2964
1893
2997
2159
2457...

output:

Unauthorized output

result:


Subtask #3:

score: 0
Runtime Error

Test #5:

score: 0
Runtime Error

input:

3 1 334547
8234

output:

Unauthorized output

result:


Subtask #4:

score: 0
Skipped

Dependency #3:

0%

Subtask #5:

score: 0
Skipped

Dependency #4:

0%

Subtask #6:

score: 0
Runtime Error

Test #8:

score: 0
Runtime Error

input:

6 958477 522361
280121915553826833
734266539148641647
72849162479700582
274266741463686096
60278972064195458
828423669427600612
571432949203039978
518511460268700898
486268614705621285
19216283231217074
611458416727512530
175147354285288662
799769622289998997
400123443628688299
145546980862133838
40...

output:

Unauthorized output

result:


Subtask #7:

score: 0
Skipped

Dependency #3:

0%

Subtask #8:

score: 0
Runtime Error

Test #33:

score: 0
Runtime Error

input:

8 9963 251
831797004675585320
494759973681332858
701341496127272302
252910460485222469
250965009655458584
366193481309061299
633134388675839346
791999098066205672
196620805863610860
363773642045280947
466508590762410710
407790578717064135
181590911404670570
570642047249889864
70138464625729452
23634...

output:

Unauthorized output

result:


Subtask #9:

score: 0
Skipped

Dependency #2:

0%