Submission #112729
Source Code Expand
using System; using System.Collections.Generic; using System.Linq; using System.Text; class Program { static void Main(string[] args) { List<RainningTimes> rainningTimesList = new List<RainningTimes>(); int N = int.Parse(Console.ReadLine()); for (int i = 0; i < N; i++) { var array = Console.ReadLine().Split('-').Select(int.Parse).ToArray(); int s = array.ElementAtOrDefault(0); int e = array.ElementAtOrDefault(1); int s1 = int.Parse(s.ToString()[3].ToString()); if (s1 == 0) { } else if (s1 < 5) s -= s1; else if (s1 > 5) s -= s1 - 5; int e1 = int.Parse(e.ToString()[3].ToString()); if (e1 == 0) { } else if (e1 < 5) e += 5 - e1; else if (e1 > 5) e += 10 - e1; int length = rainningTimesList.Count; for (int j = 0; j < length;j++ ) { Console.WriteLine(" "+rainningTimesList[j].Start+":"+rainningTimesList[j].End+"について行います."); //Start地点が枠内 if (JudgeBetween(s, rainningTimesList[j])) { //End地点が枠内 if (JudgeBetween(e, rainningTimesList[j])) { Console.WriteLine(" Start 枠内 : End 枠内"); break; }//何もしない else//End地点が枠外 { rainningTimesList[j].End = e; Console.WriteLine(" Start 枠内 : End 枠外"); break; } } else//Start地点が枠外 { //End地点が枠内 if (JudgeBetween(e, rainningTimesList[j])) { rainningTimesList[j].Start = s; Console.WriteLine(" Start 枠外 : End 枠内"); break; } else//End地点が枠外 if (rainningTimesList[j].Start > s && rainningTimesList[j].End < e) { rainningTimesList[j].Start = s; rainningTimesList[j].End = e; Console.WriteLine(" Start 枠外 : End 枠外で,Start > s && End < eが認識されました"); break; } else { rainningTimesList.Add(new RainningTimes(s, e)); Console.WriteLine(" 新たな要素ですので追加致します."); break; } } } if (rainningTimesList.Count == 0) rainningTimesList.Add(new RainningTimes(s, e)); } for (int i = rainningTimesList.Count - 1; i >= 0; i--) { int s = rainningTimesList[i].Start; int e = rainningTimesList[i].End; for (int j = i - 1; j >= 0; j--) { //Start地点が枠内 if (JudgeBetween(s, rainningTimesList[j])) { //End地点が枠内 if (JudgeBetween(e, rainningTimesList[j])) { break; }//何もしない else//End地点が枠外 { rainningTimesList[j].End = e; rainningTimesList.RemoveAt(i); break; } } else//Start地点が枠外 { //End地点が枠内 if (JudgeBetween(e, rainningTimesList[j])) { rainningTimesList[j].Start = s; rainningTimesList.RemoveAt(i); break; } else//End地点が枠外 if (rainningTimesList[j].Start > s && rainningTimesList[j].End < e) { rainningTimesList[j].Start = s; rainningTimesList[j].End = e; rainningTimesList.RemoveAt(i); break; } } } } for (int i = 0; i < rainningTimesList.Count; i++) Console.WriteLine(rainningTimesList[i].Start + "-" + rainningTimesList[i].End); } //timeがrainningTimesの枠内かどうか falseは枠外 private static bool JudgeBetween(int time , RainningTimes rainningTimes) { if (rainningTimes.Start <= time && rainningTimes.End >= time) return true; return false; } } class RainningTimes { int Start, End; public RainningTimes(int start, int end) { Start = start; End = end; } }
Submission Info
Submission Time | |
---|---|
Task | D - 感雨時刻の整理 |
User | pattyo |
Language | C# (Mono 2.10.8.1) |
Score | 0 |
Code Size | 5718 Byte |
Status | CE |
Compile Error
./Main.cs(30,68): error CS0122: `RainningTimes.Start' is inaccessible due to its protection level ./Main.cs(30,99): error CS0122: `RainningTimes.End' is inaccessible due to its protection level ./Main.cs(39,50): error CS0122: `RainningTimes.End' is inaccessible due to its protection level ./Main.cs(49,50): error CS0122: `RainningTimes.Start' is inaccessible due to its protection level ./Main.cs(54,54): error CS0122: `RainningTimes.Start' is inaccessible due to its protection level ./Main.cs(54,88): error CS0122: `RainningTimes.End' is inaccessible due to its protection level ./Main.cs(56,54): error CS0122: `RainningTimes.Start' is inaccessible due to its protection level ./Main.cs(57,54): error CS0122: `RainningTimes.End' is inaccessible due to its protection level ./Main.cs(76,46): error CS0122: `RainningTimes.Start' is inaccessible due to its protection level ./Main.cs(77,46): error CS0122: `RainningTimes.End' is inaccessible due to its protection level ./Main.cs(88,50): error CS0122: `RainningTimes.End' is...