結果

問題 No.1605 Matrix Shape
ユーザー 👑 kakel-sankakel-san
提出日時 2024-02-12 23:17:58
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 1,241 bytes
コンパイル時間 8,497 ms
コンパイル使用メモリ 158,148 KB
実行使用メモリ 204,440 KB
最終ジャッジ日時 2024-02-12 23:18:16
合計ジャッジ時間 15,532 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
33,060 KB
testcase_01 AC 93 ms
33,060 KB
testcase_02 AC 78 ms
33,060 KB
testcase_03 AC 81 ms
33,188 KB
testcase_04 WA -
testcase_05 AC 81 ms
33,060 KB
testcase_06 AC 81 ms
33,188 KB
testcase_07 AC 78 ms
33,060 KB
testcase_08 AC 82 ms
33,188 KB
testcase_09 AC 77 ms
33,060 KB
testcase_10 AC 78 ms
33,060 KB
testcase_11 AC 78 ms
33,060 KB
testcase_12 AC 82 ms
33,188 KB
testcase_13 AC 78 ms
33,060 KB
testcase_14 AC 91 ms
33,060 KB
testcase_15 AC 79 ms
33,060 KB
testcase_16 AC 79 ms
33,060 KB
testcase_17 AC 78 ms
33,060 KB
testcase_18 AC 78 ms
33,060 KB
testcase_19 AC 294 ms
74,916 KB
testcase_20 AC 248 ms
69,016 KB
testcase_21 AC 232 ms
65,176 KB
testcase_22 WA -
testcase_23 AC 261 ms
74,956 KB
testcase_24 AC 259 ms
65,816 KB
testcase_25 AC 236 ms
64,756 KB
testcase_26 AC 266 ms
64,768 KB
testcase_27 AC 220 ms
64,640 KB
testcase_28 WA -
testcase_29 AC 224 ms
64,764 KB
testcase_30 AC 250 ms
69,016 KB
testcase_31 AC 251 ms
65,176 KB
testcase_32 AC 251 ms
66,576 KB
testcase_33 WA -
testcase_34 AC 215 ms
62,236 KB
testcase_35 AC 190 ms
62,828 KB
testcase_36 AC 138 ms
204,440 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (128 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

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[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var map = NArr(n);
        var cin = new int[200001];
        var cout = new int[200001];
        var eq = new int[200001];
        foreach (var arr in map) if (arr[0] != arr[1])
        {
            ++cin[arr[0]];
            ++cout[arr[1]];
        }
        var scount = 0;
        for (var i = 0; i < cin.Length; ++i)
        {
            if (cin[i] != cout[i])
            {
                scount += Math.Max(0, cin[i] - cout[i]);
            }
        }
        if (scount == 0)
        {
            var set = new HashSet<int>(map.Select(mi => mi[0]));
            WriteLine(set.Count);
        }
        else if (scount == 1)
        {
            WriteLine(1);
        }
        else
        {
            WriteLine(0);
        }
    }
}
0