2021年3月2日星期二

CodeJam 2020 Vestigium , Qualification round - Repeatedly getting WA on submitting

I am repeatedly getting WA for Test Set - 1 on submitting my code. (Note: Sample test data input produces the expected output) But when I tried to simulate the Test Set 1 by entering the inputs manually with "Test run mode" on , there was no issue. I am unable to debug any further because there is no further description apart from WA.

I am stuck.Any help is appreciated.

Below is my code in C#:

using System;  using System.Collections.Generic;  using System.Linq;  using System.Text;  using System.Threading.Tasks;    class Vestigium  {        public static int countFreqForCol(int[] arr, int n)      {          bool[] visited = new bool[n];          int count = 0;          int cnt = 0;                  for (int i = 0; i < n; i++)          {                  if (visited[i] == true)                  continue;                  count = 1;              for (int j = i + 1; j < n; j++)              {                  if (arr[i] == arr[j])                  {                      visited[j] = true;                      count++;                      if (count > 1)                      {                            cnt += 1;                          break;                      }                  }              }              }          return cnt;      }      public static int countFreqForRow(int[] arr, int n)      {          bool[] visited = new bool[n];          int count = 0;          int cnt = 0;                  for (int i = 0; i < n; i++)          {                  if (visited[i] == true)                  continue;                  count = 1;              for (int j = i + 1; j < n; j++)              {                  if (arr[i] == arr[j])                  {                      visited[j] = true;                      count++;                      if (count > 1)                      {                            cnt += 1;                          break;                      }                  }              }              break;            }          return cnt;      }      public static int getoutPut(int[,] arr1, int n)      {            int k = 0;            for (int i = 0; i < n; i++)          {              for (int j = 0; j < n; j++)              {                    int val = arr1[i, j];                      if (i == j)                  {                      k += arr1[i, j];                      break;                  }                }          }          return k;      }  }            class mainProgram  {      public static void Main()      {          try          {            int t = Convert.ToInt32(Console.ReadLine());          string output = "";          //Demo                  //Demo          for (int tc = 0; tc < t; tc++)          {                int n = Convert.ToInt32(Console.ReadLine());              string[,] arr = new string[n, n];              int[,] arr1 = new int[n, n];              string[] strArr = new string[n];              //for (int i = 0; i < 4; i++)              //{              for (int index = 0; index < n; index++)              {                  string str = Console.ReadLine();                  strArr = str.Split(' ');                  for (int j = 0; j < n; j++)                  {                      //arr[i,j] = Console.Read());                      arr1[index, j] = Convert.ToInt32(strArr[j]);                  }              }              //}                int k = Vestigium.getoutPut(arr1, n);              int[] arr2 = new int[n];              int r = 0;              int c = 0;              for (int i = 0; i < n; i++)              {                  for (int j = 0; j < n; j++)                  {                        arr2[j] = arr1[i, j];                    }                  int check = Vestigium.countFreqForRow(arr2, n);                  if (check > 0) { r += 1; }                  }                for (int i = 0; i < n; i++)              {                    for (int j = 0; j < n; j++)                  {                          arr2[j] = arr1[j, i];                  }                  int check = Vestigium.countFreqForCol(arr2, n);                  if (check > 0) { c += 1; }                  }              //Case #1: 4 0 0              output = output + "Case #" + (tc + 1).ToString() + ": " + k.ToString() + " " + r.ToString() + " " + c.ToString() + "\n";          }          Console.WriteLine(output);          Console.ReadLine();          }          catch(Exception E)          {              Console.WriteLine(E.Message);          }          }  }  
https://stackoverflow.com/questions/66451597/codejam-2020-vestigium-qualification-round-repeatedly-getting-wa-on-submitti March 03, 2021 at 02:05PM

没有评论:

发表评论