Hello,

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);
        }


    }
}


-- 
You received this message because you are subscribed to the Google Groups 
"Google Code Jam" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-code/8b5317fc-5472-4a7c-91c5-0038ff89044fn%40googlegroups.com.

Reply via email to