import java.io.*; import java.util.*; public class Validate { int[] period; // when a course is delivered int[][] curriculum; // curriculum[p][c] =1 <-> course c in period p int nCourses, nPeriods, minCredits, maxCredits, minCourses, maxCourses; String[] name; // name[i] is name of the ith course int[] credits; // credits[i] is the credits for the ith course ArrayList[] prereq; // j is in prereq[i] iff the jth course is a prerequisite for the ith course Scanner sc; public Validate(String fnameProblem,String fnameSolution) throws IOException { readBACP(fnameProblem); curriculum = new int[nPeriods][nCourses]; period = new int[nCourses]; readSolution(fnameSolution); } void readBACP(String fname) throws IOException { sc = new Scanner(new File(fname)); sc.next(); nPeriods = sc.nextInt(); sc.next(); nCourses = sc.nextInt(); sc.next(); minCredits = sc.nextInt(); sc.next(); maxCredits = sc.nextInt(); sc.next(); minCourses = sc.nextInt(); sc.next(); maxCourses = sc.nextInt(); name = new String[nCourses]; credits = new int[nCourses]; prereq = new ArrayList[nCourses]; readCourses(); readPrerequisites(); sc.close(); } void readCourses() throws IOException { sc.next(); // skip "courses" for (int i=0;i(); } } int find(String s,String[] dict){ for (int i=0;i maxCredits){ System.out.println("Credit violation in period "+ p); valid = false; } totalCredits = totalCredits + creditsInPeriod; maxCreditsInAllPeriods = Math.max(maxCreditsInAllPeriods,creditsInPeriod); } // is course limit respected? for (int p=0;p maxCourses){ System.out.println("Course violation in period "+ p); valid = false; } } return valid; } void show() { int maxCreditsInAllPeriods = Integer.MIN_VALUE; int minCreditsInAllPeriods = Integer.MAX_VALUE; int totalCredits = 0; for (int p=0;p