提出 #50775147


ソースコード 拡げる

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;

namespace Tasks;

public class B
{
    public static void Main()
    {
        using var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }

    public static void Solve()
    {
        var N = Scanner.Scan<int>();
        var A = new int[N][];
        for (var i = 0; i < N; i++)
        {
            A[i] = Scanner.ScanEnumerable<int>().ToArray();
        }

        for (var i = 0; i < N; i++)
        {
            var list = new List<int>();
            for (var j = 0; j < N; j++)
            {
                if (A[i][j] == 1)
                {
                    list.Add(j + 1);
                }
            }

            Console.WriteLine(string.Join(" ", list));
        }
    }

    public static class Scanner
    {
        public static T Scan<T>() where T : IConvertible => Convert<T>(ScanStringArray()[0]);
        public static (T1, T2) Scan<T1, T2>() where T1 : IConvertible where T2 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]));
        }
        public static (T1, T2, T3) Scan<T1, T2, T3>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]));
        }
        public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]));
        }
        public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]));
        }
        public static (T1, T2, T3, T4, T5, T6) Scan<T1, T2, T3, T4, T5, T6>() where T1 : IConvertible where T2 : IConvertible where T3 : IConvertible where T4 : IConvertible where T5 : IConvertible where T6 : IConvertible
        {
            var input = ScanStringArray();
            return (Convert<T1>(input[0]), Convert<T2>(input[1]), Convert<T3>(input[2]), Convert<T4>(input[3]), Convert<T5>(input[4]), Convert<T6>(input[5]));
        }
        public static IEnumerable<T> ScanEnumerable<T>() where T : IConvertible => ScanStringArray().Select(Convert<T>);
        private static string[] ScanStringArray()
        {
            var line = Console.ReadLine()?.Trim() ?? string.Empty;
            return string.IsNullOrEmpty(line) ? Array.Empty<string>() : line.Split(' ');
        }
        private static T Convert<T>(string value) where T : IConvertible => (T)System.Convert.ChangeType(value, typeof(T));
    }
}

提出情報

提出日時
問題 B - Adjacency Matrix
ユーザ AconCavy
言語 C# 11.0 (.NET 7.0.7)
得点 150
コード長 3295 Byte
結果 AC
実行時間 63 ms
メモリ 27816 KiB

ジャッジ結果

セット名 Sample All
得点 / 配点 0 / 0 150 / 150
結果
AC × 3
AC × 17
セット名 テストケース
Sample sample00.txt, sample01.txt, sample02.txt
All sample00.txt, sample01.txt, sample02.txt, testcase00.txt, testcase01.txt, testcase02.txt, testcase03.txt, testcase04.txt, testcase05.txt, testcase06.txt, testcase07.txt, testcase08.txt, testcase09.txt, testcase10.txt, testcase11.txt, testcase12.txt, testcase13.txt
ケース名 結果 実行時間 メモリ
sample00.txt AC 52 ms 26424 KiB
sample01.txt AC 60 ms 26256 KiB
sample02.txt AC 48 ms 26316 KiB
testcase00.txt AC 50 ms 27116 KiB
testcase01.txt AC 43 ms 27324 KiB
testcase02.txt AC 50 ms 27424 KiB
testcase03.txt AC 53 ms 27048 KiB
testcase04.txt AC 49 ms 27376 KiB
testcase05.txt AC 63 ms 27400 KiB
testcase06.txt AC 58 ms 27248 KiB
testcase07.txt AC 50 ms 27320 KiB
testcase08.txt AC 50 ms 27348 KiB
testcase09.txt AC 54 ms 27292 KiB
testcase10.txt AC 52 ms 27216 KiB
testcase11.txt AC 55 ms 27816 KiB
testcase12.txt AC 59 ms 27312 KiB
testcase13.txt AC 58 ms 27760 KiB