Submission #3436874
Source Code Expand
using System; using System.Collections.Generic; using System.Text; namespace AtTest.D_Challenge { class ABC_082 { static void Main(string[] args) { Method(args); Console.ReadLine(); } static void Method(string[] args) { string[] input = Read().Split('T'); var xs = new int[(input.Length + 1) / 2]; var ys = new int[input.Length / 2]; int xSum = 0; int ySum = 0; for(int i = 0; i < input.Length; i++) { if (i % 2 == 0) { xs[i / 2] = input[i].Length; //Console.WriteLine("x: " + xs[i / 2]); xSum += xs[i / 2]; } else { ys[i / 2] = input[i].Length; //Console.WriteLine("y: " + ys[i / 2]); ySum += ys[i / 2]; } } if (ys.Length == 0) ys = new int[1] { 0 }; int[] tarXY = ReadInts(); bool xOK = false; bool yOK = false; var xSums = new Dictionary<int, bool>(); xSums.Add(0, true); var ySums = new Dictionary<int, bool>(); ySums.Add(0, true); if (xs.Length == 1)//最初は+のみ { xOK = xs[0] == tarXY[0]; } else { for (int i = 1; i < xs.Length; i++) { var tempDict = new Dictionary<int, bool>(); foreach (int key in xSums.Keys) { int val = key + xs[i]; if (xSum - val * 2 == tarXY[0] || (val+xs[0]) * 2 - xSum == tarXY[0]) { xOK = true; } else { tempDict.Add(key + xs[i], true); } } if (xOK) break; foreach (int key in tempDict.Keys) { if (!xSums.ContainsKey(key)) { xSums.Add(key, true); } } } } for (int i = 0; i < ys.Length; i++) { var tempDict = new Dictionary<int, bool>(); foreach (int key in ySums.Keys) { int val = key + ys[i]; if (ySum - val * 2 == tarXY[1] || val * 2 - ySum == tarXY[1]) { yOK = true; } else { tempDict.Add(key + ys[i], true); } } if (yOK) break; foreach (int key in tempDict.Keys) { if (!ySums.ContainsKey(key)) { ySums.Add(key, true); } } } if (xOK && yOK) { Console.WriteLine("Yes"); } else { Console.WriteLine("No"); } } private static string Read() { return Console.ReadLine(); } private static int ReadInt() { return int.Parse(Read()); } private static long ReadLong() { return long.Parse(Read()); } private static double ReadDouble() { return double.Parse(Read()); } private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); } private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); } private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); } } }
Submission Info
Submission Time | |
---|---|
Task | D - FT Robot |
User | MiuraMiuMiu |
Language | C# (Mono 4.6.2.0) |
Score | 500 |
Code Size | 4166 Byte |
Status | AC |
Exec Time | 445 ms |
Memory | 37584 KB |
Judge Result
Set Name | Sample | All | ||||
---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 500 / 500 | ||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt |
All | 0_00.txt, 0_01.txt, 0_02.txt, 0_03.txt, 0_04.txt, 0_05.txt, 1_00.txt, 1_01.txt, 1_02.txt, 1_03.txt, 1_04.txt, 1_05.txt, 1_06.txt, 1_07.txt, 1_08.txt, 1_09.txt, 1_10.txt, 1_11.txt, 1_12.txt, 1_13.txt, 1_14.txt, 1_15.txt, 1_16.txt, 1_17.txt, 1_18.txt, 1_19.txt, 1_20.txt, 1_21.txt, 1_22.txt, 1_23.txt, 1_24.txt, 1_25.txt, 1_26.txt, 1_27.txt, 1_28.txt, 1_29.txt, 1_30.txt, 1_31.txt, 1_32.txt, 1_33.txt, 1_34.txt, 1_35.txt, 1_36.txt, 1_37.txt, 1_38.txt, 1_39.txt, 1_40.txt, 1_41.txt, 1_42.txt, 1_43.txt, 1_44.txt, 1_45.txt, 1_46.txt, 1_47.txt, 1_48.txt, 1_49.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
0_00.txt | AC | 23 ms | 11104 KB |
0_01.txt | AC | 23 ms | 9172 KB |
0_02.txt | AC | 22 ms | 9056 KB |
0_03.txt | AC | 23 ms | 9172 KB |
0_04.txt | AC | 23 ms | 13152 KB |
0_05.txt | AC | 24 ms | 11104 KB |
1_00.txt | AC | 24 ms | 13280 KB |
1_01.txt | AC | 23 ms | 9184 KB |
1_02.txt | AC | 23 ms | 9184 KB |
1_03.txt | AC | 23 ms | 11232 KB |
1_04.txt | AC | 23 ms | 11232 KB |
1_05.txt | AC | 23 ms | 11264 KB |
1_06.txt | AC | 349 ms | 33500 KB |
1_07.txt | AC | 346 ms | 37584 KB |
1_08.txt | AC | 331 ms | 35376 KB |
1_09.txt | AC | 329 ms | 37424 KB |
1_10.txt | AC | 320 ms | 35376 KB |
1_11.txt | AC | 325 ms | 37320 KB |
1_12.txt | AC | 25 ms | 11232 KB |
1_13.txt | AC | 106 ms | 32584 KB |
1_14.txt | AC | 24 ms | 13280 KB |
1_15.txt | AC | 25 ms | 11232 KB |
1_16.txt | AC | 25 ms | 13280 KB |
1_17.txt | AC | 187 ms | 33304 KB |
1_18.txt | AC | 42 ms | 17752 KB |
1_19.txt | AC | 326 ms | 31408 KB |
1_20.txt | AC | 39 ms | 18008 KB |
1_21.txt | AC | 344 ms | 35428 KB |
1_22.txt | AC | 49 ms | 19540 KB |
1_23.txt | AC | 187 ms | 35348 KB |
1_24.txt | AC | 47 ms | 22484 KB |
1_25.txt | AC | 191 ms | 37420 KB |
1_26.txt | AC | 24 ms | 13280 KB |
1_27.txt | AC | 25 ms | 13280 KB |
1_28.txt | AC | 24 ms | 11232 KB |
1_29.txt | AC | 186 ms | 33200 KB |
1_30.txt | AC | 24 ms | 13280 KB |
1_31.txt | AC | 262 ms | 33248 KB |
1_32.txt | AC | 24 ms | 11232 KB |
1_33.txt | AC | 102 ms | 32580 KB |
1_34.txt | AC | 24 ms | 13280 KB |
1_35.txt | AC | 61 ms | 31836 KB |
1_36.txt | AC | 26 ms | 10208 KB |
1_37.txt | AC | 70 ms | 31964 KB |
1_38.txt | AC | 25 ms | 11744 KB |
1_39.txt | AC | 45 ms | 21344 KB |
1_40.txt | AC | 30 ms | 16096 KB |
1_41.txt | AC | 35 ms | 16352 KB |
1_42.txt | AC | 159 ms | 31408 KB |
1_43.txt | AC | 50 ms | 13408 KB |
1_44.txt | AC | 445 ms | 33584 KB |
1_45.txt | AC | 99 ms | 34640 KB |
1_46.txt | AC | 28 ms | 11232 KB |
1_47.txt | AC | 97 ms | 34640 KB |
1_48.txt | AC | 98 ms | 32592 KB |
1_49.txt | AC | 227 ms | 37488 KB |