Submission #59173917


Source Code Expand

Copy
N,M = map(int,input().split())
ans = N*N
ng = set()
def f(x,y):
return 1<=x<=N and 1<=y<=N
for _ in range(M):
a,b = map(int,input().split())
ng.add((a,b))
if f(a+2,b+1):
ng.add((a+2,b+1))
if f(a+1,b+2):
ng.add((a+1,b+2))
if f(a-1,b+2):
ng.add((a-1,b+2))
if f(a-2,b+1):
ng.add((a-2,b+1))
if f(a-2,b-1):
ng.add((a-2,b-1))
if f(a-1,b-2):
ng.add((a-1,b-2))
if f(a+1,b-2):
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
N,M = map(int,input().split())
ans = N*N
ng = set()
def f(x,y):
    return 1<=x<=N and 1<=y<=N
for _ in range(M):
    a,b = map(int,input().split())
    ng.add((a,b))
    if f(a+2,b+1):
        ng.add((a+2,b+1))
    if f(a+1,b+2):
        ng.add((a+1,b+2))
    if f(a-1,b+2):
        ng.add((a-1,b+2))
    if f(a-2,b+1):
        ng.add((a-2,b+1))
    if f(a-2,b-1):
        ng.add((a-2,b-1))
    if f(a-1,b-2):
        ng.add((a-1,b-2))
    if f(a+1,b-2):
        ng.add((a+1,b-2))
    if f(a+2,b-1):
        ng.add((a+2,b-1))
print(ans-len(ng))

Submission Info

Submission Time
Task C - Avoid Knight Attack
User Lingdao
Language Python (PyPy 3.10-v7.3.12)
Score 300
Code Size 569 Byte
Status AC
Exec Time 757 ms
Memory 286712 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 300 / 300
Status
AC × 3
AC × 35
Set Name Test Cases
Sample 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt
All 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt, 01_random_25.txt, 01_random_26.txt, 01_random_27.txt, 01_random_28.txt, 01_random_29.txt, 01_random_30.txt, 01_random_31.txt, 01_random_32.txt, 01_random_33.txt, 01_random_34.txt
Case Name Status Exec Time Memory
00_sample_00.txt AC 63 ms 76668 KB
00_sample_01.txt AC 64 ms 76744 KB
00_sample_02.txt AC 64 ms 76612 KB
01_random_03.txt AC 743 ms 109568 KB
01_random_04.txt AC 757 ms 180200 KB
01_random_05.txt AC 698 ms 286712 KB
01_random_06.txt AC 682 ms 285988 KB
01_random_07.txt AC 685 ms 282536 KB
01_random_08.txt AC 701 ms 279364 KB
01_random_09.txt AC 214 ms 94364 KB
01_random_10.txt AC 621 ms 137704 KB
01_random_11.txt AC 382 ms 184684 KB
01_random_12.txt AC 120 ms 103680 KB
01_random_13.txt AC 518 ms 195228 KB
01_random_14.txt AC 138 ms 118096 KB
01_random_15.txt AC 64 ms 76568 KB
01_random_16.txt AC 62 ms 76528 KB
01_random_17.txt AC 64 ms 76408 KB
01_random_18.txt AC 63 ms 76556 KB
01_random_19.txt AC 63 ms 76540 KB
01_random_20.txt AC 63 ms 76564 KB
01_random_21.txt AC 65 ms 76664 KB
01_random_22.txt AC 64 ms 76484 KB
01_random_23.txt AC 721 ms 109512 KB
01_random_24.txt AC 742 ms 157552 KB
01_random_25.txt AC 718 ms 191812 KB
01_random_26.txt AC 722 ms 191648 KB
01_random_27.txt AC 735 ms 189852 KB
01_random_28.txt AC 719 ms 189312 KB
01_random_29.txt AC 91 ms 82772 KB
01_random_30.txt AC 215 ms 95152 KB
01_random_31.txt AC 450 ms 174660 KB
01_random_32.txt AC 102 ms 90560 KB
01_random_33.txt AC 67 ms 76812 KB
01_random_34.txt AC 374 ms 152292 KB


2025-02-28 (Fri)
05:10:24 +00:00