結果
問題 | No.30 たこやき工場 |
ユーザー |
![]() |
提出日時 | 2017-05-30 13:20:10 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 30 ms / 5,000 ms |
コード長 | 1,738 bytes |
コンパイル時間 | 1,067 ms |
コンパイル使用メモリ | 113,032 KB |
実行使用メモリ | 19,456 KB |
最終ジャッジ日時 | 2024-12-21 05:26:25 |
合計ジャッジ時間 | 2,499 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System; using System.Collections.Generic; using System.Linq; using System.Collections; using System.Linq.Expressions; static class Program { static void Main() { new Magatro().Solve(); } } class Magatro { private int N, M; private List<int>[] A; private List<uint>[]B; private uint[][] Memo; private void Scan() { N = int.Parse(Console.ReadLine()); M = int.Parse(Console.ReadLine()); A = new List<int>[N]; B = new List<uint>[N]; for (int i = 0; i < N; i++) { A[i] = new List<int>(); B[i] = new List<uint>(); } for (int i = 0; i < M; i++) { var line = Console.ReadLine().Split(' '); int p = int.Parse(line[0]) - 1; uint q = uint.Parse(line[1]); int r = int.Parse(line[2]) - 1; A[r].Add(p); B[r].Add(q); } } private uint[] Make(int num) { if (Memo[num] != null) { return Memo[num]; } var result = new uint[N]; if(A[num].Count == 0) { result[num] = 1; Memo[num] = result.ToArray(); return result; } for(int i = 0; i < A[num].Count; i++) { var r = Make(A[num][i]); for(int j = 0; j < N; j++) { result[j] += r[j] * B[num][i]; } } Memo[num] = result.ToArray(); return result; } public void Solve() { Scan(); Memo = new uint[N][]; var ans = Make(N - 1); for(int i = 0; i < N-1; i++) { Console.WriteLine(ans[i]); } } }