結果
問題 | No.2042 RGB Caps |
ユーザー | 👑 kakel-san |
提出日時 | 2022-08-19 21:49:54 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 88 ms / 2,000 ms |
コード長 | 2,480 bytes |
コンパイル時間 | 3,029 ms |
コンパイル使用メモリ | 116,144 KB |
実行使用メモリ | 33,292 KB |
最終ジャッジ日時 | 2024-04-27 20:33:02 |
合計ジャッジ時間 | 4,727 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
27,080 KB |
testcase_01 | AC | 25 ms
24,908 KB |
testcase_02 | AC | 23 ms
23,348 KB |
testcase_03 | AC | 31 ms
25,260 KB |
testcase_04 | AC | 25 ms
23,480 KB |
testcase_05 | AC | 24 ms
25,420 KB |
testcase_06 | AC | 33 ms
31,564 KB |
testcase_07 | AC | 47 ms
33,292 KB |
testcase_08 | AC | 64 ms
31,464 KB |
testcase_09 | AC | 34 ms
29,216 KB |
testcase_10 | AC | 82 ms
31,312 KB |
testcase_11 | AC | 30 ms
27,368 KB |
testcase_12 | AC | 85 ms
31,572 KB |
testcase_13 | AC | 86 ms
29,404 KB |
testcase_14 | AC | 88 ms
29,392 KB |
testcase_15 | AC | 25 ms
27,372 KB |
testcase_16 | AC | 42 ms
27,156 KB |
testcase_17 | AC | 29 ms
25,420 KB |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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(int n) => Enumerable.Repeat(0, n).Select(_ => NList).ToArray(); static void Main() { var c = NList; var (n, k) = (c[0], c[1]); var list = new char[n]; for (var _ = 0; _ < k; ++_) { var s = ReadLine().Split(); list[int.Parse(s[0]) - 1] = s[1][0]; } var res = new char[n]; var x = new string[] { "RGB", "RBG", "GBR", "GRB", "BRG", "BGR" }; for (var i = 0; i < n; i += 3) { var info = list.Skip(i).Take(3).ToList(); foreach (var xi in x) { if (Fit(info, xi)) { for (var j = 0; j < info.Count; ++j) { res[i + j] = xi[j]; } break; } } } WriteLine(res); } static bool Fit(List<char> info, string x) { var r = false; var g = false; var b = false; if (info[0] == 'R') { if (x[0] != 'R') return false; r = true; } else if (info[0] == 'G') { if (x[0] != 'G') return false; g = true; } else if (info[0] == 'B') { if (x[0] != 'B') return false; b = true; } if (info.Count == 1) return true; if (info[1] == 'R') { if (!r && x[1] != 'R') return false; r = true; } else if (info[1] == 'G') { if (!g && x[1] != 'G') return false; g = true; } else if (info[1] == 'B') { if (!b && x[1] != 'B') return false; b = true; } if (info.Count == 2) return true; if (info[2] == 'R') { if (!r && x[2] != 'R') return false; } else if (info[2] == 'G') { if (!g && x[2] != 'G') return false; } else if (info[2] == 'B') { if (!b && x[2] != 'B') return false; } return true; } }