結果

問題 No.2403 "Eight" Bridges of Königsberg
ユーザー FromBooskaFromBooska
提出日時 2023-08-05 12:02:30
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 825 bytes
コンパイル時間 343 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 76,672 KB
最終ジャッジ日時 2024-04-23 09:12:36
合計ジャッジ時間 4,220 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 41 ms
51,712 KB
testcase_01 AC 39 ms
51,840 KB
testcase_02 AC 38 ms
51,840 KB
testcase_03 AC 39 ms
52,096 KB
testcase_04 AC 112 ms
76,160 KB
testcase_05 AC 145 ms
76,488 KB
testcase_06 AC 154 ms
76,672 KB
testcase_07 AC 118 ms
76,416 KB
testcase_08 AC 125 ms
76,544 KB
testcase_09 AC 155 ms
76,288 KB
testcase_10 AC 150 ms
76,544 KB
testcase_11 AC 132 ms
76,288 KB
testcase_12 AC 153 ms
76,672 KB
testcase_13 AC 129 ms
76,032 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 47 ms
60,544 KB
testcase_20 AC 45 ms
59,392 KB
testcase_21 AC 46 ms
59,776 KB
testcase_22 AC 48 ms
60,544 KB
testcase_23 AC 46 ms
60,672 KB
testcase_24 AC 50 ms
61,184 KB
testcase_25 AC 45 ms
59,648 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 68 ms
70,784 KB
testcase_29 WA -
testcase_30 AC 51 ms
61,504 KB
testcase_31 AC 70 ms
70,656 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

# 頂点すべてに達するのではなく辺すべてに達する(使う)
# まず多重辺は打ち消しあう分を消そう、いらないから
# 自己ループも消そう、いらないから
# それから、辺が何本の線になっているか
# degreeをinward, outwardで数えるか
# outward-inwardでプラスをすべて数えればそれが線の数
# 答えはそこから1を引けばいいか、やってみよう
# WA出た、多重辺の打ち消しあいをやめよう、そうしないと多重辺のところに行けない

N, M = map(int, input().split())
inward = [0]*(N+1)
outward = [0]*(N+1)
for i in range(M):
    u, v = map(int, input().split())
    outward[u] += 1
    inward[v] += 1

count = 0
for i in range(1, N+1):
    count += max(0, outward[i]-inward[i])
ans = count-1
print(ans)
0