ACMICPC Contest Scoring

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Dec 2007
Posts: 4
Reputation: mizcomscie is an unknown quantity at this point 
Solved Threads: 0
mizcomscie mizcomscie is offline Offline
Newbie Poster

ACMICPC Contest Scoring

 
0
  #1
Dec 9th, 2007
  1. import java.io.*;
  2.  
  3. public class ACMICPCContestScoring
  4. {
  5.  
  6. public static void main(String[] args) throws IOException
  7. {
  8. BufferedReader dataIn = new BufferedReader(new InputStreamReader(System.in));
  9. BufferedReader br = new BufferedReader(new FileReader (" "));
  10.  
  11.  
  12. String s = br.readLine();
  13. String[] array1 = s.split(" ");
  14. int numberOfTeams = Integer.parseInt(array1[0]);
  15. int numberOfProblems = Integer.parseInt(array1[1]);
  16. String[] timeStarted = array1[2].split(":");
  17.  
  18.  
  19. String[][] arrayTeamsStatusForProblems = new String[numberOfTeams][numberOfProblems];
  20. int[] arrayTeamsStatusForTimePenalty = new int[numberOfTeams];
  21. int[][] arrayTeamsStatusForTimePenaltyTemp = new int[numberOfTeams][numberOfProblems];
  22.  
  23. for (int i = 0; i < numberOfTeams; i++)
  24. {
  25. for (int j = 0; j < numberOfProblems; j++)
  26. {
  27. arrayTeamsStatusForProblems[i][j] = "U";
  28. }
  29. }
  30.  
  31. int[] numberOfProblemAttempts = new int[numberOfProblems];
  32. int[] numberOfAcceptedProblems = new int[numberOfProblems];
  33. int[] numberOfRejectedProblems = new int[numberOfProblems];
  34. int[][] arrayTeamsTimeOfLastAcceptedRun = new int[numberOfTeams][2];
  35.  
  36. while (true)
  37. {
  38. String str = br.readLine();
  39.  
  40. if (str != null)
  41. {
  42. String[] arrayStr = str.split(" ");
  43. arrayTeamsStatusForProblems[Integer.parseInt(arrayStr[1]) - 1][Integer.parseInt(arrayStr[2]) - 1] = arrayStr[3];
  44.  
  45. if (arrayStr[3].equals("Y"))
  46. {
  47. numberOfAcceptedProblems[Integer.parseInt(arrayStr[2]) - 1]++;
  48.  
  49. String[] timeSolved = arrayStr[0].split(":");
  50.  
  51. arrayTeamsStatusForTimePenalty[Integer.parseInt(arrayStr[1]) - 1] += ((Integer.parseInt(timeSolved[0]) - Integer.parseInt(timeStarted[0])) * 60) + (Integer.parseInt(timeSolved[1]) - Integer.parseInt(timeStarted[1])); // ADD THE NUMBER OF ELAPSED MINUTES SINCE THE START OF THE CONTEST
  52.  
  53. if (arrayTeamsStatusForTimePenaltyTemp[Integer.parseInt(arrayStr[1]) - 1][Integer.parseInt(arrayStr[2]) - 1] > 0)
  54. {
  55. arrayTeamsStatusForTimePenalty[Integer.parseInt(arrayStr[1]) - 1] += arrayTeamsStatusForTimePenaltyTemp[Integer.parseInt(arrayStr[1]) - 1][Integer.parseInt(arrayStr[2]) - 1]; // ADD THE PREVIOUS COUNTED PENALTY POINTS FROM THE TEMP ARRAY
  56. }
  57.  
  58. arrayTeamsTimeOfLastAcceptedRun[Integer.parseInt(arrayStr[1]) - 1][0] = Integer.parseInt(timeSolved[0]);
  59. arrayTeamsTimeOfLastAcceptedRun[Integer.parseInt(arrayStr[1]) - 1][1] = Integer.parseInt(timeSolved[1]);
  60. }
  61. else if (arrayStr[3].equals("N"))
  62. {
  63. numberOfRejectedProblems[Integer.parseInt(arrayStr[2]) - 1]++;
  64. arrayTeamsStatusForTimePenaltyTemp[Integer.parseInt(arrayStr[1]) - 1][Integer.parseInt(arrayStr[2]) - 1] += 20;
  65. }
  66.  
  67. numberOfProblemAttempts[Integer.parseInt(arrayStr[2]) - 1]++;
  68. }
  69. else
  70. {
  71. break;
  72. }
  73. }
  74.  
  75. br.close();
  76.  
  77.  
  78. System.out.println();
  79.  
  80. int[] numberOfSolvedProblems = new int[numberOfTeams];
  81. for (int i = 0; i < numberOfSolvedProblems.length; i++)
  82. {
  83. int ctrSolvedProblems = 0;
  84.  
  85. for (int j = 0; j < numberOfProblems; j++)
  86. {
  87. if (arrayTeamsStatusForProblems[i][j].equals("Y"))
  88. {
  89. ctrSolvedProblems++;
  90. }
  91. }
  92.  
  93. numberOfSolvedProblems[i] = ctrSolvedProblems;
  94.  
  95.  
  96. int[] arrayRankOfTeams = new int[numberOfTeams];
  97.  
  98. for (int o = 0; o < numberOfTeams; o++)
  99. {
  100. arrayRankOfTeams[i] = i + 1;
  101. }
  102.  
  103. for (int k = 0; k < numberOfTeams - 1; k++)
  104. {
  105. for (int j = i + 1; j < numberOfTeams; j++)
  106. {
  107. if (numberOfSolvedProblems[i] < numberOfSolvedProblems[j]) // FIRST PHASE: ACCORDING TO THE NUMBER OF PROBLEMS SOLVED
  108. {
  109. int temp = numberOfSolvedProblems[i];
  110. numberOfSolvedProblems[i] = numberOfSolvedProblems[j];
  111. numberOfSolvedProblems[j] = temp;
  112.  
  113. int temp2 = arrayTeamsStatusForTimePenalty[i];
  114. arrayTeamsStatusForTimePenalty[i] = arrayTeamsStatusForTimePenalty[j];
  115. arrayTeamsStatusForTimePenalty[j] = temp2;
  116.  
  117. int temp3 = arrayRankOfTeams[i];
  118. arrayRankOfTeams[i] = arrayRankOfTeams[j];
  119. arrayRankOfTeams[j] = temp3;
  120. }
  121. else if (numberOfSolvedProblems[i] == numberOfSolvedProblems[j])
  122. {
  123. if (arrayTeamsStatusForTimePenalty[i] > arrayTeamsStatusForTimePenalty[j])
  124. {
  125. int temp = numberOfSolvedProblems[i];
  126. numberOfSolvedProblems[i] = numberOfSolvedProblems[j];
  127. numberOfSolvedProblems[j] = temp;
  128.  
  129. int temp2 = arrayTeamsStatusForTimePenalty[i];
  130. arrayTeamsStatusForTimePenalty[i] = arrayTeamsStatusForTimePenalty[j];
  131. arrayTeamsStatusForTimePenalty[j] = temp2;
  132.  
  133. int temp3 = arrayRankOfTeams[i];
  134. arrayRankOfTeams[i] = arrayRankOfTeams[j];
  135. arrayRankOfTeams[j] = temp3;
  136. }
  137. else if (arrayTeamsStatusForTimePenalty[i] > 0 && arrayTeamsStatusForTimePenalty[i] == arrayTeamsStatusForTimePenalty[j])
  138. {
  139. if (arrayTeamsTimeOfLastAcceptedRun[i][0] < arrayTeamsTimeOfLastAcceptedRun[j][0])
  140. {
  141. int temp = numberOfSolvedProblems[i];
  142. numberOfSolvedProblems[i] = numberOfSolvedProblems[j];
  143. numberOfSolvedProblems[j] = temp;
  144.  
  145. int temp2 = arrayTeamsStatusForTimePenalty[i];
  146. arrayTeamsStatusForTimePenalty[i] = arrayTeamsStatusForTimePenalty[j];
  147. arrayTeamsStatusForTimePenalty[j] = temp2;
  148.  
  149. int temp3 = arrayRankOfTeams[i];
  150. arrayRankOfTeams[i] = arrayRankOfTeams[j];
  151. arrayRankOfTeams[j] = temp3;
  152. }
  153. else if (arrayTeamsTimeOfLastAcceptedRun[i][0] == arrayTeamsTimeOfLastAcceptedRun[j][0] && arrayTeamsTimeOfLastAcceptedRun[i][1] < arrayTeamsTimeOfLastAcceptedRun[j][1])
  154. {
  155. int temp = numberOfSolvedProblems[i];
  156. numberOfSolvedProblems[i] = numberOfSolvedProblems[j];
  157. numberOfSolvedProblems[j] = temp;
  158.  
  159. int temp2 = arrayTeamsStatusForTimePenalty[i];
  160. arrayTeamsStatusForTimePenalty[i] = arrayTeamsStatusForTimePenalty[j];
  161. arrayTeamsStatusForTimePenalty[j] = temp2;
  162.  
  163. int temp3 = arrayRankOfTeams[i];
  164. arrayRankOfTeams[i] = arrayRankOfTeams[j];
  165. arrayRankOfTeams[j] = temp3;
  166. }
  167. }
  168. else
  169. {
  170. if (i > j)
  171. {
  172. int temp3 = arrayRankOfTeams[i];
  173. arrayRankOfTeams[i] = arrayRankOfTeams[j];
  174. arrayRankOfTeams[j] = temp3;
  175. }
  176. }
  177. }
  178. }
  179. }
  180.  
  181. // OUTPUT
  182.  
  183. PrintWriter pw = new PrintWriter(new FileWriter("renjei.txt"));
  184.  
  185. pw.println("CONTEST RESULTS");
  186. pw.printf("%10s", "RANK");
  187. pw.printf("%10s", "TEAM");
  188. pw.printf("%10s", "SOLVED");
  189. pw.printf("%10s%n", "PENALTY");
  190.  
  191. for (int a = 0, rank = 1; a < numberOfTeams; a++, rank++)
  192. {
  193. pw.printf("%10s", rank);
  194. pw.printf("%10s", arrayRankOfTeams[i]);
  195. pw.printf("%10s", numberOfSolvedProblems[i]);
  196. pw.printf("%10s%n", arrayTeamsStatusForTimePenalty[i]);
  197.  
  198. if (i + 1 < numberOfTeams && numberOfSolvedProblems[i] == numberOfSolvedProblems[i + 1] && arrayTeamsStatusForTimePenalty[i] == arrayTeamsStatusForTimePenalty[i + 1])
  199. {
  200. rank--;
  201. }
  202. else
  203. {
  204. rank = i + 1;
  205. }
  206. }
  207.  
  208. pw.println();
  209. pw.println("PROBLEM SOLUTION STATISTICS");
  210. pw.printf("%10s", "PROBLEM");
  211. pw.printf("%10s", "ATTEMPTS");
  212. pw.printf("%10s", "ACCEPTED");
  213. pw.printf("%10s%n", "REJECTED");
  214.  
  215. for (int n = 0; n < numberOfProblems; n++)
  216. {
  217. pw.printf("%10d", (i + 1));
  218. pw.printf("%10d", numberOfProblemAttempts[i]);
  219. pw.printf("%10d", numberOfAcceptedProblems[i]);
  220. pw.printf("%10d%n", numberOfRejectedProblems[i]);
  221. }
  222.  
  223. pw.close();
  224.  
  225.  
  226.  
  227.  
  228. System.out.println();
  229.  
  230. for (int m = 0; m < numberOfTeams; m++)
  231. {
  232. System.out.print("Team #" + (i + 1) + ": ");
  233. for (int j = 0; j < numberOfProblems; j++)
  234. {
  235. System.out.print(arrayTeamsStatusForProblems[i][j] + ",");
  236. }
  237. System.out.println();
  238. }
  239.  
  240.  
  241. System.out.println();
  242.  
  243. for (int h = 0; h < numberOfTeams; h++)
  244. {
  245. System.out.println("Team #" + (i + 1) + " solved " + numberOfSolvedProblems[i] + " problems.");
  246. }
  247.  
  248.  
  249. System.out.println();
  250.  
  251. for (int g = 0; g < numberOfTeams; g++)
  252. {
  253. System.out.print("Total Time Penalty of Team #" + (i + 1) + ": " + arrayTeamsStatusForTimePenalty[i]);
  254. System.out.println();
  255. }
  256.  
  257. System.out.println();
  258.  
  259. for (int f = 0; f < numberOfTeams; f++)
  260. {
  261. System.out.print("Rank #" + (i + 1) + ": " + arrayRankOfTeams[i]);
  262. System.out.println();
  263. }
  264.  
  265. }
  266. }
  267. }
Last edited by ~s.o.s~; Dec 16th, 2007 at 8:54 am. Reason: Added code tags, learn to use them.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: ACMICPC Contest Scoring

 
0
  #2
Dec 10th, 2007
And? What is this for? What is it suppossed to be, other than a procedural program masquerading as a Java program?

Did you have a question? Or did you simply want to show the world that you
1) Have no idea what OOP is
2) Have no idea how to post code to a forum
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 4
Reputation: mizcomscie is an unknown quantity at this point 
Solved Threads: 0
mizcomscie mizcomscie is offline Offline
Newbie Poster

Re: ACMICPC Contest Scoring

 
0
  #3
Dec 10th, 2007
I want to complete this program. I don't know the functions of each codes that's why I can't execute the program correctly. Can you help me please.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: ACMICPC Contest Scoring

 
0
  #4
Dec 10th, 2007
Maybe. If you post the code correctly (use code tags) and actually ask a specific question, and give detailed explanations of what, up to this point, is not working as it should, and what the difference is.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Dec 2007
Posts: 4
Reputation: mizcomscie is an unknown quantity at this point 
Solved Threads: 0
mizcomscie mizcomscie is offline Offline
Newbie Poster

Re: ACMICPC Contest Scoring

 
0
  #5
Dec 13th, 2007
the program is said to be process completed but the problem is I cant trace the concept of the program.
Reply With Quote Quick reply to this message  
Join Date: Feb 2006
Posts: 2,467
Reputation: masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of masijade has much to be proud of 
Solved Threads: 267
Moderator
masijade's Avatar
masijade masijade is offline Offline
Nearly a Posting Maven

Re: ACMICPC Contest Scoring

 
0
  #6
Dec 13th, 2007
And I have no idea what you mean with that statement.

Is this your code? If so, what problem are you having with it? If not, ask the entity from which you received the code.
Java Programmer and Sun Systems Administrator

----------------------------------------------

Debugging is twice as hard as writing the code in the first place. Therefore, if you write the code as cleverly as possible, you are, by definition, not smart enough to debug it.
--Brian Kernighan
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 1,297
Reputation: majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about majestic0110 has a spectacular aura about 
Solved Threads: 68
majestic0110's Avatar
majestic0110 majestic0110 is offline Offline
Nearly a Posting Virtuoso

Re: ACMICPC Contest Scoring

 
0
  #7
Dec 15th, 2007
I would hazard a guess that is partly mizconscie's code and part 'borrowed' !
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC