Wednesday, September 17, 2008

2008 MGPT-4 solution

------------------------------------
File: prob1.java
------------------------------------
import ncst.pgdst.*;

class prob1{

public char makdir(char ch, char dir){

if(dir == 'L'){
if(ch == 'N')
return 'W';
else if(ch == 'W')
return 'S';
else if(ch == 'S')
return 'E';
else if(ch == 'E')
return 'N';
}
else if(dir == 'R'){
if(ch == 'N')
return 'E';
else if(ch == 'W')
return 'N';
else if(ch == 'S')
return 'W';
else if(ch == 'E')
return 'S';
}
return '\0';
}

public static void main(String arg[]) throws IOException{
SimpleInput si = new SimpleInput();
int maxX = si.readInt();
int maxY = si.readInt();

int curX = si.readInt();
int curY = si.readInt();
si.skipWhite();
char dir = si.readChar();
//System.out.println(dir);
String s = si.readWord();

prob1 p =new prob1();

for(int i=0; i< dir ="="" dir ="=""> 0)
curY--;
}else if(dir == 'S'){
if(curX > 0)
curX--;
}
}
}
System.out.println(curX+" "+curY+" "+dir);
}
}

************************************
------------------------------------
File: tree.java
------------------------------------
import ncst.pgdst.*;

class tree{
int val;
public static tree root;
tree left;
tree right;
tree(){
root = null;
left = null;
right = null;
}
tree(int n){
left = null;
right = null;
val =n;
}
public int findIndex(int n, int in[]){
for(int i=0; i t2)
return 1;
else
return 2;
}

public static void main(String arg[]) throws IOException{
SimpleInput si = new SimpleInput();
int n = si.readInt();
int pre[] = new int [n];
int in[] = new int[n];
for(int i=0; i******