QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#437617#8786. The Whole Worlducup-team1004TL 15ms10748kbPython3982b2024-06-09 14:10:462024-06-09 14:10:47

Judging History

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

  • [2024-06-09 14:10:47]
  • 评测
  • 测评结果:TL
  • 用时:15ms
  • 内存:10748kb
  • [2024-06-09 14:10:46]
  • 提交

answer

T=int(input())
def binom(n,m):
	if 0>n or m>n:
		return 0
	ans=1
	for i in range(m):
		ans=ans*(n-i)//(i+1)
	return ans
while T>0:
	n=int(input())
	x=[0 for i in range(n)]
	y=[0 for i in range(n)]
	for i in range(n):
		x[i],y[i]=map(int,input().split(' '))
	a=[[0 for j in range(n)] for i in range(n)]
	def insert(a,n,x):
		for i in range(n):
			while x[i]:
				w=a[i][i]//x[i]
				for j in range(i,n):
					a[i][j]-=x[j]*w
				a[i],x=x,a[i]
		for i in range(n-1,-1,-1):
			if a[i][i]==0:
				continue
			for j in range(i):
				w=a[j][i]/a[i][i]
				for k in range(i,n):
					a[j][k]-=a[i][k]*w
	def check(a,n,x):
		for i in range(n):
			if x[i]==0:
				continue
			if a[i][i]==0 or x[i]%a[i][i]!=0:
				return 0
			w=x[i]//a[i][i]
			for j in range(i,n):
				x[j]-=a[i][j]*w
		return 1
	ans=0
	while 1:
		v=[]
		for i in range(n):
			v.append(binom(x[i],ans))
		insert(a,n,v)
		if check(a,n,y):
			print(ans)
			break
		ans+=1
	T-=1

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 10ms
memory: 10632kb

input:

2
2
1 0
4 1
3
1 1
4 4
6 6

output:

3
1

result:

ok 2 number(s): "3 1"

Test #2:

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

input:

2
2
1 0
4 1
3
1 0
3 0
5 4

output:

3
3

result:

ok 2 number(s): "3 3"

Test #3:

score: -100
Time Limit Exceeded

input:

2
10
1 557
2 -172
3 -497
5 763
6 -149
7 -355
8 -29
9 -588
10 -171
11 -355
10
1 -461
2 -219
3 -45
4 -212
5 749
6 -294
9 -85
10 213
11 -412
12 125

output:


result: