QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#226677#5408. 计数鸡xyz1230 33ms28592kbC++142.1kb2023-10-26 13:31:272023-10-26 13:31:28

Judging History

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

  • [2023-10-26 13:31:28]
  • 评测
  • 测评结果:0
  • 用时:33ms
  • 内存:28592kb
  • [2023-10-26 13:31:27]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const long long mod=998244353;
long long T,a,b,c,d[1000001],v[1000001],g[301][301],o,f[1000001],h[1000001],fa[1000001],q,w,e,an,cn,fac[1000001],inv[1000001],st[1000001],u[1000001];
char s[1000001];
struct p{long long q,w;}l[1000001];
long long pow_(long long qq,long long ww){long long ee=1;while(ww){if(ww&1) ee*=qq,ee%=mod;qq*=qq,qq%=mod,ww>>=1;}return ee%mod;}
inline int read(){int x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9'){x=(x<<3)+(x<<1)+c-'0';c=getchar();}return x*f;}
void add(long long qq,long long ww){l[++o].q=ww,l[o].w=h[qq],h[qq]=o;}
long long gcd(long long qq,long long ww){return !ww?qq:gcd(ww,qq%ww);}
long long find(long long qq){return qq==fa[qq]?qq:fa[qq]=find(fa[qq]);}
void merge(long long qq,long long ww){long long f1=find(qq),f2=find(ww);if(f1==f2) return;fa[f1]=f2;}
long long C(long long qq,long long ww){return fac[qq]*inv[ww]%mod*inv[qq-ww]%mod;}
int main()
{
//	freopen("1.in","r",stdin);
	srand((unsigned)(time(0)^(*new int)));
	fac[0]=1;for(int i=1;i<=1000000;i++) fac[i]=fac[i-1]*i%mod;
	inv[1000000]=pow_(fac[1000000],mod-2);for(int i=999999;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	T=1;
//	scanf("%lld",&T);
	for(int ii=1;ii<=T;ii++)
	{
		scanf("%lld",&a);
		for(int i=1;i<=a;i++) scanf("%lld",&d[i]);
		for(int i=1;i<=a;i++) scanf("%lld",&f[i]);
		for(int i=1;i<=a;i++)
		{
			for(int j=1;j<=a;j++)
			{
				g[i][j]=1;
				for(int k=i+1;k<=a;k++) if(j+f[i]>=d[k]) g[i][j]*=-1;
			} 
		}
//		for(int i=1;i<=a;i++){for(int j=1;j<=a;j++) cout<<g[i][j]<<" ";cout<<"\n";}
		an=1;
		for(int i=1;i<=a;i++)
		{
			long long tt=0;
			for(int j=i;j<=a;j++)
			{
				if(g[j][i])
				{
					tt=j;break;
				}
			}
			if(!tt){an=0;break;}
			if(((tt-i)*(tt-i+1)/2)%2==1) an=-an;
			for(int j=1;j<=a;j++) swap(g[i][j],g[tt][j]);
			for(int j=i+1;j<=a;j++)
			{
				long long gg=pow_(g[i][i],mod-2)%mod*g[j][i]%mod;
				for(int k=i;k<=a;k++) g[j][k]=(g[j][k]-g[i][k]*gg)%mod;
			}
		}
		for(int i=1;i<=a;i++) an=an*g[i][i]%mod;
		printf("%lld",((an+fac[a])%mod*pow_(2,mod-2)%mod+mod)%mod);
	}
	return 0;
}

详细

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 20
Accepted
time: 12ms
memory: 26324kb

input:

20
20 4 15 16 11 3 7 18 9 5 13 8 6 12 2 10 1 17 14 19
-7 -11 9 -3 -20 -13 -18 15 0 8 0 12 -16 -19 8 -9 -4 -2 6 -10

output:

699910446

result:

ok 1 number(s): "699910446"

Test #2:

score: -20
Wrong Answer
time: 3ms
memory: 28432kb

input:

20
11 6 3 18 17 19 4 8 10 15 12 16 1 13 7 14 5 20 9 2
13 9 -1 1 9 -11 -19 8 -5 -11 -4 3 17 1 8 1 0 -11 -16 -10

output:

705415470

result:

wrong answer 1st numbers differ - expected: '694405422', found: '705415470'

Subtask #2:

score: 0
Wrong Answer

Test #11:

score: 30
Accepted
time: 8ms
memory: 28336kb

input:

15
14 4 15 10 11 3 7 1 9 5 13 8 6 12 2
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

output:

985377138

result:

ok 1 number(s): "985377138"

Test #12:

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

input:

15
1 2 12 4 8 13 6 5 9 3 11 10 7 14 15
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

output:

985385330

result:

ok 1 number(s): "985385330"

Test #13:

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

input:

15
7 13 6 10 3 5 2 15 11 8 9 14 12 1 4
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

output:

985377138

result:

ok 1 number(s): "985377138"

Test #14:

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

input:

15
1 6 4 2 9 14 13 12 11 15 3 10 7 8 5
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

output:

985385330

result:

ok 1 number(s): "985385330"

Test #15:

score: 0
Accepted
time: 32ms
memory: 26444kb

input:

290
210 151 231 91 180 53 275 208 138 4 251 83 136 247 22 64 104 39 120 218 51 26 203 196 280 153 191 163 161 159 241 175 284 132 17 236 11 211 142 162 107 259 246 257 47 54 165 172 70 274 219 267 289 67 237 286 1 222 194 144 146 281 9 65 89 87 171 5 271 71 285 94 283 81 261 42 260 157 244 213 127 2...

output:

68391778

result:

ok 1 number(s): "68391778"

Test #16:

score: -30
Wrong Answer
time: 33ms
memory: 28592kb

input:

293
1 170 64 256 155 245 196 19 106 108 262 104 235 56 232 6 143 140 226 65 177 202 174 133 193 263 96 191 176 114 113 91 161 290 165 30 128 83 152 53 240 139 12 154 156 118 203 252 90 68 49 208 153 59 21 198 66 280 163 182 105 149 35 79 220 239 236 151 3 276 269 93 127 189 225 237 110 228 212 109 3...

output:

579577066

result:

wrong answer 1st numbers differ - expected: '31579777', found: '579577066'

Subtask #3:

score: 0
Skipped

Dependency #1:

0%