fork(2) download
  1. package gcj2013.template;
  2.  
  3. import java.io.*;
  4. import java.util.*;
  5. import java.util.concurrent.*;
  6. import java.math.*;
  7.  
  8. import static java.lang.Math.*;
  9. import static java.lang.Character.*;
  10. import static java.util.Arrays.*;
  11. import static java.util.Collections.*;
  12. import static java.math.BigInteger.*;
  13.  
  14. public class Template implements Runnable {
  15. private static final char PROB = Template.class.getSimpleName().charAt(0);
  16. private static final boolean isPractice = false;
  17. private static final Mode mode = Mode.SAMPLE;
  18.  
  19. private static class Solver implements Callable<String> {
  20. private static final double EPS = 1e-12;
  21. private static final int INF = 1 << 20;
  22. private static final int[] di = { -1, 0, 0, 1 };
  23. private static final int[] dj = { 0, -1, 1, 0 };
  24.  
  25. // shared table
  26. static {
  27. // :TODO
  28. }
  29.  
  30. // parse
  31. public Solver(final Scanner sc) {
  32. // :TODO
  33. }
  34.  
  35. // solve
  36. @Override
  37. public String call() {
  38. // :TODO
  39. throw null;
  40. }
  41. }
  42.  
  43. // Template
  44. @Override
  45. public void run() {
  46. try (final Scanner sc = new Scanner(System.in)) {
  47. final List<Future<String>> list = new ArrayList<>();
  48. final int T = sc.nextInt();
  49. for (int i = 0; i < T; i++)
  50. list.add(es.submit(new Solver(sc)));
  51. for (int t = 1; t <= T; t++) {
  52. debugf("Case #%s%n", t);
  53. System.out.printf("Case #%s: %s%n", t, list.get(t - 1).get());
  54. }
  55. debug("done.");
  56. } catch (Exception e) {
  57. e.printStackTrace();
  58. }
  59. }
  60.  
  61. public static void main(String... args) {
  62. final Template t = new Template();
  63. switch (mode) {
  64. case SAMPLE:
  65. t.run();
  66. break;
  67. case SMALL: {
  68. String in = PROB + "-small" + (isPractice ? "-practice" : "-attempt" + 0) + ".in";
  69. String out = PROB + "-small.out";
  70. if (!isPractice)
  71. for (int i = 1; new File(PROB + "-small" + "-attempt" + i + ".in").exists(); i++)
  72. in = PROB + "-small" + "-attempt" + i + ".in";
  73. try {
  74. System.setOut(new PrintStream(out));
  75. t.run();
  76. } catch (Exception e) {
  77. e.printStackTrace();
  78. System.exit(0);
  79. }
  80. break;
  81. }
  82. case SMALL_ALL: {
  83. try {
  84. if (!isPractice)
  85. for (int i = 0; new File(PROB + "-small" + "-attempt" + i + ".in").exists(); i++) {
  86. final String in = PROB + "-small" + "-attempt" + i + ".in";
  87. t.run();
  88. }
  89. else {
  90. System.setIn(new BufferedInputStream(new FileInputStream(PROB + "-small-practice.in")));
  91. t.run();
  92. }
  93. } catch (Exception e) {
  94. e.printStackTrace();
  95. System.exit(0);
  96. }
  97. break;
  98. }
  99. case LARGE: {
  100. try {
  101. final String in = PROB + "-large" + (isPractice ? "-practice" : "") + ".in";
  102. final String out = PROB + "-large.out";
  103. System.setOut(new PrintStream(out));
  104. t.run();
  105. } catch (Exception e) {
  106. e.printStackTrace();
  107. System.exit(0);
  108. }
  109. break;
  110. }
  111. case LARGE1: {
  112. try {
  113. final String in = PROB + "-large" + (isPractice ? "-practice" : "") + "-1.in";
  114. final String out = PROB + "-large-1.out";
  115. System.setOut(new PrintStream(out));
  116. t.run();
  117. } catch (Exception e) {
  118. e.printStackTrace();
  119. System.exit(0);
  120. }
  121. break;
  122. }
  123. case LARGE2: {
  124. try {
  125. final String in = PROB + "-large" + (isPractice ? "-practice" : "") + "-2.in";
  126. final String out = PROB + "-large-2.out";
  127. System.setOut(new PrintStream(out));
  128. t.run();
  129. } catch (Exception e) {
  130. e.printStackTrace();
  131. System.exit(0);
  132. }
  133. break;
  134. }
  135. default:
  136. throw null;
  137. }
  138. es.shutdown();
  139. }
  140.  
  141. private static final int DEFAULT_PARARELL = Runtime.getRuntime().availableProcessors() + 1;
  142. private static final ExecutorService es = Executors.newFixedThreadPool(DEFAULT_PARARELL);
  143.  
  144. private static enum Mode {
  145. SAMPLE, SMALL, SMALL_ALL, LARGE, LARGE1, LARGE2
  146. }
  147.  
  148. private static void debugf(String format, Object... os) {
  149. System.err.printf(format, os);
  150. }
  151.  
  152. private static void debug(Object... os) {
  153. System.err.println(deepToString(os));
  154. }
  155. }
  156.  
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty