提出 #69085684


ソースコード 拡げる

from sys import stdin
def input():
    return stdin.readline().rstrip("\n")

n, m = map(lambda s_: int(s_), input().split())
flip = [n % 2] * (n - 1)
for _ in range(m):
    x, y = map(lambda s_: int(s_) - 1, input().split())
    if y < n - 1:
        flip[x] ^= 1
        flip[y] ^= 1
    else:
        flip[x] ^= 1
z = flip.count(0)
ans = (n - 1) * (n - 2) // 2
ans += len(flip) - z + z // 2
print(ans)




提出情報

提出日時
問題 B - Triangle Toggle
ユーザ wasd314
言語 Python (PyPy 3.10-v7.3.12)
得点 500
コード長 429 Byte
結果 AC
実行時間 100 ms
メモリ 84408 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 500 / 500
結果
AC × 3
AC × 22
セット名 テストケース
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_handmade_00.txt, 01_handmade_01.txt, 01_handmade_02.txt, 01_handmade_03.txt, 01_handmade_04.txt, 01_handmade_05.txt, 01_handmade_06.txt, 01_handmade_07.txt, 01_handmade_08.txt, 02_random_00.txt, 02_random_01.txt, 02_random_02.txt, 02_random_03.txt, 02_random_04.txt, 02_random_05.txt, 02_random_06.txt, 02_random_07.txt, 02_random_08.txt, 02_random_09.txt
ケース名 結果 実行時間 メモリ
00_sample_00.txt AC 56 ms 76312 KiB
00_sample_01.txt AC 56 ms 76440 KiB
00_sample_02.txt AC 59 ms 77660 KiB
01_handmade_00.txt AC 57 ms 77912 KiB
01_handmade_01.txt AC 83 ms 84408 KiB
01_handmade_02.txt AC 84 ms 84136 KiB
01_handmade_03.txt AC 56 ms 76536 KiB
01_handmade_04.txt AC 56 ms 76332 KiB
01_handmade_05.txt AC 56 ms 76500 KiB
01_handmade_06.txt AC 56 ms 76496 KiB
01_handmade_07.txt AC 88 ms 82560 KiB
01_handmade_08.txt AC 89 ms 82472 KiB
02_random_00.txt AC 88 ms 83148 KiB
02_random_01.txt AC 92 ms 83052 KiB
02_random_02.txt AC 76 ms 83468 KiB
02_random_03.txt AC 98 ms 83128 KiB
02_random_04.txt AC 75 ms 82576 KiB
02_random_05.txt AC 100 ms 84252 KiB
02_random_06.txt AC 85 ms 84100 KiB
02_random_07.txt AC 99 ms 84260 KiB
02_random_08.txt AC 97 ms 84140 KiB
02_random_09.txt AC 98 ms 83932 KiB