/*Using the Java language, have the function OptimalAssignments(strArr) read strArr which will represent an NxN matrix and it will be in the following format: ["(n,n,n...)","(...)",...] where the n's represent integers. This matrix represents a machine at row i performing task at column j. The cost for this is matrix[i][j]. Your program should determine what machine should perform what task so as to minimize the whole cost and it should return the pairings of machines to tasks in the following format: (i-j)(...)... Only one machine can perform one task. For example: if strArr is ["(5,4,2)","(12,4,3)","(3,4,13)"] then your program should return (1-3)(2-2)(3-1) because assigning the machines to these tasks gives the least cost. The matrix will range from 2x2 to 6x6, there will be no negative costs in the matrix, and there will always be a unique answer*/
import java.util.*;
import java.io.*;
class Function {
String OptimalAssignments(String strArr) {
// code goes here
/* Note: In Java the return type of a function and the
parameter types being passed are defined, so this return
call must match the return type of the function.
You are free to modify the return type. */
int[][] mat=new int[3][3];
String[] arr=strArr.split("\\)");
String[] a1=arr[0].split("\\(");
String[] a2=arr[1].split("\\(");
String[] a3=arr[2].split("\\(");
String[] r1=a1[1].split(",");
String[] r2=a2[1].split(",");
String[] r3=a3[1].split(",");
for(int k=0;k<3;k++)
mat[0][k]=Integer.parseInt(r1[k]);
for(int s=0;s<3;s++)
mat[1][s]=Integer.parseInt(r2[s]);
for(int p=0;p<3;p++)
mat[2][p]=Integer.parseInt(r3[p]);
/* for (int y=0;y<3;y++)
for (int r=0;r<3;r++)
System.out.println(mat[y][r]);
*/
Function d=new Function();
int[] sum=d.mincost_map(mat,0);
strArr="\"(1-"+sum[0]+")(2-"+sum[1]+")(3-"+sum[2]+")\"";
return strArr;
}
public int[] mincost_map(int[][] a,int b){
int[] c=new int[3];
Function f=new Function();
//int[][] arr=new int[b][b];
c[0]=f.find_min(a,0,3);
c[1]=f.find_min(a,1,c[0]);
c[2]=f.find_min(a,2,c[1]);
return c;
}
public int find_min(int[][] a,int r,int num){
int sum=a[r][0];
int q=0;
for(int y=0;y<3;y++){
if(a[r][y]<sum)
{
if(y==num)
continue;
else { sum=a[r][y]; q=y;}
}
}
return q;
}
public static void main (String[] args) throws Exception{
// keep this function call here
BufferedReader s=new BufferedReader(new InputStreamReader(System.in));
String str=s.readLine();
Function c = new Function();
//String str="[\"(5,4,2)\",\"(12,4,4)\",\"(3,4,13)\"]";
System.out.print(c.OptimalAssignments(str));
//Function c=new Function();
//System.out.println(c.OptimalAssignments(str));
}
}
import java.util.*;
import java.io.*;
class Function {
String OptimalAssignments(String strArr) {
// code goes here
/* Note: In Java the return type of a function and the
parameter types being passed are defined, so this return
call must match the return type of the function.
You are free to modify the return type. */
int[][] mat=new int[3][3];
String[] arr=strArr.split("\\)");
String[] a1=arr[0].split("\\(");
String[] a2=arr[1].split("\\(");
String[] a3=arr[2].split("\\(");
String[] r1=a1[1].split(",");
String[] r2=a2[1].split(",");
String[] r3=a3[1].split(",");
for(int k=0;k<3;k++)
mat[0][k]=Integer.parseInt(r1[k]);
for(int s=0;s<3;s++)
mat[1][s]=Integer.parseInt(r2[s]);
for(int p=0;p<3;p++)
mat[2][p]=Integer.parseInt(r3[p]);
/* for (int y=0;y<3;y++)
for (int r=0;r<3;r++)
System.out.println(mat[y][r]);
*/
Function d=new Function();
int[] sum=d.mincost_map(mat,0);
strArr="\"(1-"+sum[0]+")(2-"+sum[1]+")(3-"+sum[2]+")\"";
return strArr;
}
public int[] mincost_map(int[][] a,int b){
int[] c=new int[3];
Function f=new Function();
//int[][] arr=new int[b][b];
c[0]=f.find_min(a,0,3);
c[1]=f.find_min(a,1,c[0]);
c[2]=f.find_min(a,2,c[1]);
return c;
}
public int find_min(int[][] a,int r,int num){
int sum=a[r][0];
int q=0;
for(int y=0;y<3;y++){
if(a[r][y]<sum)
{
if(y==num)
continue;
else { sum=a[r][y]; q=y;}
}
}
return q;
}
public static void main (String[] args) throws Exception{
// keep this function call here
BufferedReader s=new BufferedReader(new InputStreamReader(System.in));
String str=s.readLine();
Function c = new Function();
//String str="[\"(5,4,2)\",\"(12,4,4)\",\"(3,4,13)\"]";
System.out.print(c.OptimalAssignments(str));
//Function c=new Function();
//System.out.println(c.OptimalAssignments(str));
}
}