Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.nio.charset.StandardCharsets;
- import java.util.ArrayList;
- import java.util.Scanner;
- public class Simulator {
- public static void main(String[] args) throws IOException {
- String[] inputs = {"a_example", "b_small", "c_medium", "d_big"} ;
- for (String in: inputs) {
- Pizza pizza = new Pizza();
- pizza.parse(in+ ".in");
- pizza.calculate();
- pizza.print(in+".out");
- }
- }
- }
- ////////////////
- class Slice{
- int r1, c1, r2, c2;
- char[][] matrix;
- int min;
- public Slice(int r1, int c1, int r2, int c2, char matrix[][]) {
- this.r1 = r1;
- this.c1 = c1;
- this.r2 = r2;
- this.c2 = c2;
- this.matrix = matrix;
- }
- boolean checkMatrix(){
- int rows = Math.abs(r2 - r1);
- int cols = Math.abs(c2 - c1);
- int counterT=0;
- int counterM=0;
- for(int i=0; i<rows; i++)
- {
- for(int j=0; j<cols; j++)
- {
- if(matrix[i][j] == 'T')
- counterT++;
- if(matrix[i][j] == 'M')
- counterM++;
- }
- }
- return (counterM < min || counterT < min);
- }
- }
- ///////////////////
- import java.io.BufferedReader;
- import java.io.FileReader;
- import java.io.IOException;
- import java.io.PrintWriter;
- import java.nio.charset.StandardCharsets;
- import java.util.ArrayList;
- class Pizza{
- int rows; //number of rows
- int cols; //number of columns
- int minIng; //Minimum number of ingredients that a slice must have
- int maxCells; //Maximum number of cells a slice can have
- Character [][] matrix;
- ArrayList<Slice> slices;
- void parse(String filename) throws IOException {
- int lineCount = 0;
- BufferedReader bufferedReader = null;
- slices = new ArrayList<>();
- try {
- bufferedReader = new BufferedReader(new FileReader("HashCode/Input/" + filename));
- String line = bufferedReader.readLine();
- String[] firstLine = line.split(" ");
- rows = Integer.parseInt(firstLine[0]);
- cols = Integer.parseInt(firstLine[1]);
- minIng = Integer.parseInt(firstLine[2]);
- maxCells = Integer.parseInt(firstLine[3]);
- matrix = new Character[rows][cols];
- for (int i=0; i<rows; i++)
- {
- line = bufferedReader.readLine();
- char[] currentLine = line.toCharArray();
- for(int j=0; j<cols; j++)
- {
- matrix[i][j] = currentLine[j];
- }
- }
- }
- catch (IOException e){
- e.printStackTrace();
- }
- }
- void calculate(){
- /*
- for(int i=0; i<rows; i++)
- {
- for(int j=0; j<cols; j++)
- {
- if()
- }
- }
- */
- }
- void print(String filename){
- PrintWriter writer = null;
- try {
- writer = new PrintWriter("HashCode/Output/" + filename, StandardCharsets.UTF_8);
- for(int i=0; i<rows; i++)
- {
- for(int j=0; j<cols; j++)
- {
- writer.print(matrix[i][j]+" ");
- }
- writer.print("\n");
- }
- writer.close();
- } catch (IOException e) {
- e.printStackTrace();
- }
- //1637
- }
- }
Add Comment
Please, Sign In to add comment