コード例 #1
0
ファイル: 18.cs プロジェクト: qifanyyy/CLCDSA
 private Problem2(InputParser input)
 {
     N         = input.GetInt();
     Surprises = input.GetInt();
     Threshold = input.GetInt();
     Scores    = input.GetIntArray(N);
 }
コード例 #2
0
        public string SolveOneCase(InputParser input)
        {
            int R = input.GetInt();
            int C = input.GetInt();
            int W = input.GetInt();

            int bb = C / W * (R - 1);
            int cc = (C - 1) / W + W;


            var res = bb + cc;

            return(res.ToString());
        }
コード例 #3
0
 private Problem3(InputParser input)
 {
     A = input.GetInt();
     B = input.GetInt();
 }
コード例 #4
0
ファイル: 19.cs プロジェクト: qifanyyy/CLCDSA
 private Problem4(InputParser input)
 {
     Height   = input.GetInt();
     Width    = input.GetInt();
     Distance = input.GetInt();
     char[][] hall = input.GetStrings(Height).Select(s => s.ToCharArray()).ToArray();
     SegmentsFacingDown  = Enumerable.Range(0, Height - 1).Select(i => new List <HSegment>()).ToArray();
     SegmentsFacingUp    = Enumerable.Range(0, Height - 1).Select(i => new List <HSegment>()).ToArray();
     SegmentsFacingRight = Enumerable.Range(0, Width - 1).Select(i => new List <VSegment>()).ToArray();
     SegmentsFacingLeft  = Enumerable.Range(0, Width - 1).Select(i => new List <VSegment>()).ToArray();
     for (int h = 0; h < Height; ++h)
     {
         for (int w = 0; w < Width; ++w)
         {
             if (hall[h][w] == '#')
             {
                 if (h != Height - 1 && hall[h + 1][w] != '#')
                 {
                     if (SegmentsFacingDown[h].Count > 0 && SegmentsFacingDown[h][SegmentsFacingDown[h].Count - 1].right == w - 1)
                     {
                         SegmentsFacingDown[h][SegmentsFacingDown[h].Count - 1].right = w;
                     }
                     else
                     {
                         SegmentsFacingDown[h].Add(new HSegment()
                         {
                             left = w - 1, right = w
                         });
                     }
                 }
                 if (h != 0 && hall[h - 1][w] != '#')
                 {
                     if (SegmentsFacingUp[h - 1].Count > 0 && SegmentsFacingUp[h - 1][SegmentsFacingUp[h - 1].Count - 1].right == w - 1)
                     {
                         SegmentsFacingUp[h - 1][SegmentsFacingUp[h - 1].Count - 1].right = w;
                     }
                     else
                     {
                         SegmentsFacingUp[h - 1].Add(new HSegment()
                         {
                             left = w - 1, right = w
                         });
                     }
                 }
                 if (w != Width - 1 && hall[h][w + 1] != '#')
                 {
                     if (SegmentsFacingRight[w].Count > 0 && SegmentsFacingRight[w][SegmentsFacingRight[w].Count - 1].bottom == h - 1)
                     {
                         SegmentsFacingRight[w][SegmentsFacingRight[w].Count - 1].bottom = h;
                     }
                     else
                     {
                         SegmentsFacingRight[w].Add(new VSegment()
                         {
                             top = h - 1, bottom = h
                         });
                     }
                 }
                 if (w != 0 && hall[h][w - 1] != '#')
                 {
                     if (SegmentsFacingLeft[w - 1].Count > 0 && SegmentsFacingLeft[w - 1][SegmentsFacingLeft[w - 1].Count - 1].bottom == h - 1)
                     {
                         SegmentsFacingLeft[w - 1][SegmentsFacingLeft[w - 1].Count - 1].bottom = h;
                     }
                     else
                     {
                         SegmentsFacingLeft[w - 1].Add(new VSegment()
                         {
                             top = h - 1, bottom = h
                         });
                     }
                 }
             }
             else if (hall[h][w] == 'X')
             {
                 InitialX = w - 0.5;
                 InitialY = h - 0.5;
             }
         }
     }
 }
コード例 #5
0
ファイル: 18.cs プロジェクト: qifanyyy/CLCDSA
        public string SolveOneCase(InputParser input)
        {
            R = input.GetInt();
            C = input.GetInt();

            str = new string[R];
            for (int i = 0; i < R; i++)
            {
                str[i] = input.GetString();
            }
            count = 0;

            for (int i = 0; i < R; i++)
            {
                for (int j = 0; j < C; j++)
                {
                    var  c = str[i][j];
                    bool t = navigate(i, j, true, c);
                    if (!t)
                    {
                        if (c != '<')
                        {
                            var x = navigate(i, j, true, '<');
                            if (x)
                            {
                                count++;
                                continue;
                            }
                        }
                        if (c != '^')
                        {
                            var x = navigate(i, j, true, '^');
                            if (x)
                            {
                                count++;
                                continue;
                            }
                        }
                        if (c != '>')
                        {
                            var x = navigate(i, j, true, '>');
                            if (x)
                            {
                                count++;
                                continue;
                            }
                        }
                        if (c != 'v')
                        {
                            var x = navigate(i, j, true, 'v');
                            if (x)
                            {
                                count++;
                                continue;
                            }
                        }
                        return(IMP);
                    }
                }
            }


            return(count.ToString());
        }