Created
March 19, 2018 04:34
-
-
Save kevin51jiang/dea6480192af1e37584a7b418f53c3eb to your computer and use it in GitHub Desktop.
For the "NOT ENOUGH SERVERS" problem on DMOJ.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package pkg2011_s1; | |
import java.io.BufferedReader; | |
import java.io.IOException; | |
import java.io.InputStreamReader; | |
import java.util.StringTokenizer; | |
/** | |
* | |
* @author Kevin Jiang | |
*/ | |
public class Main { | |
public static boolean[][] tests; | |
/** | |
* returns a boolean arr with 'O' being true | |
* and 'X' being false. | |
* @param str | |
* @return | |
*/ | |
public static boolean[] processLine(String str){ | |
boolean[] results = new boolean[str.length()]; | |
for (int i = 0; i < results.length; i++) { | |
if(str.charAt(i) == 'O'){//accepted | |
results[i] = true; | |
}else{//'X', unaccepted | |
results[i] = false; | |
} | |
} | |
return results; | |
} | |
/** | |
* finds to see if there is a false AT ALL in the arr | |
* @param arr | |
* @return | |
*/ | |
public static boolean finalResult(boolean[] arr){ | |
for (int i = 0; i < arr.length; i++) { | |
if(!arr[i]){ | |
return false; | |
} | |
} | |
return true; | |
} | |
public static void doStuff(BufferedReader reader) throws IOException{ | |
StringTokenizer st = new StringTokenizer(reader.readLine()); | |
int numTesters = Integer.parseInt(st.nextToken()); | |
int numCase = Integer.parseInt(st.nextToken()); | |
tests = new boolean[numTesters][numCase]; | |
for (int i = 0; i < numTesters; i++) { | |
tests[i] = processLine(reader.readLine()); | |
} | |
//make a FINAL, const array for the desired overall results | |
boolean[] ref = new boolean[numTesters]; | |
for (int i = 0; i < numTesters; i++) { | |
ref[i] = finalResult(tests[i]); | |
} | |
int numReqTest = 1; | |
int[] reqTests; | |
for (numReqTest = 1; numReqTest < numTesters; numReqTest++) { | |
reqTests = findGood(numReqTest); | |
} | |
} | |
private static int[] findGood(int numReqTest) { | |
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates. | |
} | |
/** | |
* @param args the command line arguments | |
* @throws java.io.IOException | |
*/ | |
public static void main(String[] args) throws IOException { | |
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); | |
doStuff(reader); | |
reader.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Not yet finished.