結果

問題 No.2403 "Eight" Bridges of Königsberg
ユーザー 👑 kakel-sankakel-san
提出日時 2023-08-04 22:03:53
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,502 bytes
コンパイル時間 2,877 ms
コンパイル使用メモリ 115,692 KB
実行使用メモリ 37,328 KB
最終ジャッジ日時 2024-04-22 20:20:52
合計ジャッジ時間 7,144 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
19,200 KB
testcase_01 AC 35 ms
19,200 KB
testcase_02 AC 32 ms
18,944 KB
testcase_03 AC 34 ms
18,944 KB
testcase_04 AC 127 ms
27,008 KB
testcase_05 AC 226 ms
31,872 KB
testcase_06 AC 248 ms
33,280 KB
testcase_07 AC 156 ms
27,648 KB
testcase_08 AC 176 ms
28,544 KB
testcase_09 AC 252 ms
31,744 KB
testcase_10 AC 248 ms
32,256 KB
testcase_11 AC 191 ms
29,312 KB
testcase_12 AC 252 ms
33,792 KB
testcase_13 AC 178 ms
28,544 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 32 ms
19,200 KB
testcase_19 AC 53 ms
29,940 KB
testcase_20 AC 34 ms
20,596 KB
testcase_21 AC 42 ms
23,168 KB
testcase_22 AC 53 ms
29,440 KB
testcase_23 AC 53 ms
29,564 KB
testcase_24 AC 52 ms
29,184 KB
testcase_25 AC 52 ms
29,184 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 52 ms
28,800 KB
testcase_29 WA -
testcase_30 AC 38 ms
22,400 KB
testcase_31 AC 54 ms
29,308 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[] NMi => ReadLine().Split().Select(c => int.Parse(c) - 1).ToArray();
    static int[][] NMap(int n) => Enumerable.Repeat(0, n).Select(_ => NMi).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (n, m) = (c[0], c[1]);
        var map = NMap(m);
        var tree = new List<int>[n];
        for (var i = 0; i < tree.Length; ++i) tree[i] = new List<int>();
        foreach (var edge in map) tree[edge[0]].Add(edge[1]);

        var starts = new int[n];
        var ends = new int[n];
        for (var i = 0; i < n; ++i)
        {
            while (tree[i].Count > 0)
            {
                ++starts[i];
                var pos = i;
                do
                {
                    var next = tree[pos][tree[pos].Count - 1];
                    tree[pos].RemoveAt(tree[pos].Count - 1);
                    pos = next;
                } while (tree[pos].Count > 0);
                ++ends[pos];
            }
        }
        for (var i = 0; i < n; ++i)
        {
            var rm = Math.Min(starts[i], ends[i]);
            starts[i] -= rm;
        }
        WriteLine(Math.Max(0, starts.Sum() - 1));
    }
}
0