QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#234464 | #3837. The Matching System | ucup-team1001# | AC ✓ | 14ms | 8232kb | Python3 | 930b | 2023-11-01 17:31:21 | 2023-11-01 17:31:21 |
Judging History
answer
def binpow(a, b, m):
a = a % m
res = 1
while b > 0:
if b & 1:
res = res * a % m
a = a * a % m
b >>= 1
return res
mod = 10 ** 9 + 7
n = int(input())
if n == 1:
print("*")
print("0")
print(1)
print("*")
print("0")
print(2)
elif n == 2:
print("*0")
print("00")
print(3)
print("**")
print("00")
print(4)
else:
print("*" * (n - 2) + "0*")
print("0" + "1" * (n - 1))
ans = 1
for i in range(1, n):
ans *= i + n - 1
ans %= mod
ans *= binpow(i, mod - 2, mod)
ans %= mod
ans *= 5 * (n - 1) * (n - 1) + 5 * (n - 1) + 2
ans %= mod
ans *= binpow(2 * n * (n + 1), mod - 2, mod)
ans %= mod
print(ans)
print("*" + "1" * ((n - 3) // 2) + '0' + '*' * (n // 2))
print("1" * (n - 1) + "0")
print((n * n + 6 * n + 1) // 4)
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 3ms
memory: 8076kb
input:
3
output:
*0* 011 8 *0* 110 7
result:
ok Accepted
Test #2:
score: 0
Accepted
time: 2ms
memory: 8056kb
input:
1
output:
* 0 1 * 0 2
result:
ok Accepted
Test #3:
score: 0
Accepted
time: 4ms
memory: 8088kb
input:
2
output:
*0 00 3 ** 00 4
result:
ok Accepted
Test #4:
score: 0
Accepted
time: 5ms
memory: 8084kb
input:
4
output:
**0* 0111 31 *0** 1110 10
result:
ok Accepted
Test #5:
score: 0
Accepted
time: 5ms
memory: 8056kb
input:
5
output:
***0* 01111 119 *10** 11110 14
result:
ok Accepted
Test #6:
score: 0
Accepted
time: 4ms
memory: 8048kb
input:
6
output:
****0* 011111 456 *10*** 111110 18
result:
ok Accepted
Test #7:
score: 0
Accepted
time: 2ms
memory: 8184kb
input:
10
output:
********0* 0111111111 99892 *1110***** 1111111110 40
result:
ok Accepted
Test #8:
score: 0
Accepted
time: 10ms
memory: 8088kb
input:
20
output:
******************0* 01111111111111111111 31775330 *111111110********** 11111111111111111110 130
result:
ok Accepted
Test #9:
score: 0
Accepted
time: 12ms
memory: 8180kb
input:
30
output:
****************************0* 011111111111111111111111111111 37652369 *11111111111110*************** 111111111111111111111111111110 270
result:
ok Accepted
Test #10:
score: 0
Accepted
time: 6ms
memory: 8132kb
input:
50
output:
************************************************0* 01111111111111111111111111111111111111111111111111 637736708 *111111111111111111111110************************* 11111111111111111111111111111111111111111111111110 700
result:
ok Accepted
Test #11:
score: 0
Accepted
time: 0ms
memory: 8208kb
input:
100
output:
**************************************************************************************************0* 0111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 990322733 *1111111111111111111111111111111111111111111111110**************************************...
result:
ok Accepted
Test #12:
score: 0
Accepted
time: 11ms
memory: 8124kb
input:
200
output:
******************************************************************************************************************************************************************************************************0* 011111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111...
result:
ok Accepted
Test #13:
score: 0
Accepted
time: 8ms
memory: 8232kb
input:
499
output:
************************************************************************************************************************************************************************************************************************************************************************************************************...
result:
ok Accepted
Test #14:
score: 0
Accepted
time: 14ms
memory: 8212kb
input:
888
output:
************************************************************************************************************************************************************************************************************************************************************************************************************...
result:
ok Accepted
Test #15:
score: 0
Accepted
time: 10ms
memory: 8076kb
input:
999
output:
************************************************************************************************************************************************************************************************************************************************************************************************************...
result:
ok Accepted
Test #16:
score: 0
Accepted
time: 13ms
memory: 8084kb
input:
1000
output:
************************************************************************************************************************************************************************************************************************************************************************************************************...
result:
ok Accepted