結果

問題 No.2593 Reorder and Mod 120
ユーザー 👑 kakel-sankakel-san
提出日時 2023-12-22 22:10:46
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 157 ms / 2,000 ms
コード長 1,486 bytes
コンパイル時間 6,916 ms
コンパイル使用メモリ 157,796 KB
実行使用メモリ 179,688 KB
最終ジャッジ日時 2023-12-22 22:10:57
合計ジャッジ時間 10,430 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 59 ms
31,780 KB
testcase_01 AC 60 ms
31,780 KB
testcase_02 AC 61 ms
31,908 KB
testcase_03 AC 61 ms
31,908 KB
testcase_04 AC 62 ms
31,908 KB
testcase_05 AC 60 ms
31,780 KB
testcase_06 AC 61 ms
31,908 KB
testcase_07 AC 58 ms
31,780 KB
testcase_08 AC 56 ms
31,524 KB
testcase_09 AC 57 ms
31,524 KB
testcase_10 AC 59 ms
31,780 KB
testcase_11 AC 65 ms
32,036 KB
testcase_12 AC 73 ms
32,292 KB
testcase_13 AC 149 ms
33,060 KB
testcase_14 AC 96 ms
32,548 KB
testcase_15 AC 130 ms
32,804 KB
testcase_16 AC 71 ms
32,292 KB
testcase_17 AC 94 ms
32,548 KB
testcase_18 AC 89 ms
32,420 KB
testcase_19 AC 144 ms
32,932 KB
testcase_20 AC 157 ms
33,060 KB
testcase_21 AC 157 ms
33,060 KB
testcase_22 AC 156 ms
33,060 KB
testcase_23 AC 157 ms
33,060 KB
testcase_24 AC 65 ms
32,804 KB
testcase_25 AC 63 ms
32,804 KB
testcase_26 AC 68 ms
179,688 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (98 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());

    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var n = NN;
        var s = ReadLine();
        if (n == 1)
        {
            WriteLine(1);
            return;
        }
        var count = new int[10];
        foreach (var si in s) ++count[si - '0'];
        var set = new HashSet<int>();
        for (var i = 1; i < 10; ++i)
        {
            if (count[i] == 0) continue;
            --count[i];
            for (var j = 1; j < 10; ++j)
            {
                if (count[j] == 0) continue;
                --count[j];
                var tmp = 0;
                var evens = 0;
                var odds = 0;
                for (var c = 1; c < 10; ++c)
                {
                    for (var p = 0; p < count[c]; ++p) tmp = (tmp * 10 + c) % 120;
                    if (count[c] > 0)
                    {
                        if (c % 2 == 0) ++evens;
                        else ++odds;
                    }
                }
                tmp = (tmp * 100 + i * 10 + j) % 120;
                set.Add(tmp);
                if (evens > 0 && odds > 0) set.Add((tmp + 60) % 120);
                ++count[j];
            }
            ++count[i];
        }
        WriteLine(set.Count);
    }
}
0