I have this basic code for processing input. It works on my IDE and even compiles and runs fine on the IDE at Codechef for custom input. However, when i let it run without custom input it throws an NZEC error. I reckon some problem in how i am reading input. Any help appreciated.
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
namespace *****
{
class Program
{
public class testInput
{
public int T;
public List<testCase> testCases = new List<testCase>();
public void print()
{
Console.WriteLine(T);
foreach (testCase t in testCases) { t.print(); }
}
public void read()
{
T = int.Parse(Console.ReadLine());
for (int i = 0; i < T; i++)
{
var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var F = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var P = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
var tC = new testCase(NM[0], NM[1], P, F);
testCases.Add(tC);
}
}
public void readfromfile()
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), @"..\..\..\testCase1.txt");
StreamReader sr = new StreamReader(path);
T = int.Parse(sr.ReadLine());
for (int i = 0; i < T; i++)
{
var NM = Array.ConvertAll(sr.ReadLine().Split(' '), int.Parse);
var F = Array.ConvertAll(sr.ReadLine().Split(' '), int.Parse);
var P = Array.ConvertAll(sr.ReadLine().Split(' '), int.Parse);
var tC = new testCase(NM[0], NM[1], P, F);
testCases.Add(tC);
}
}
}
public class testCase
{
public int N, M;
public int[] P, F;
public testCase(int N, int M, int[] P, int[] F) {
this.N = N;
this.M = M;
this.P = P;
this.F = F; }
public void print() {
Console.WriteLine(String.Join(" ", new int[] { N, M }));
Console.WriteLine(String.Join(" ", F));
Console.WriteLine(String.Join(" ", P));
}
}
static void Main(string[] args)
{
testInput test = new testInput();
//test.readfromfile();
test.read();
//test.print();
foreach(testCase t in test.testCases)
{
//Solve Problem
}
//Console.ReadKey();
}
}
}