|
1 | | -import java.io.*; |
2 | | -import java.math.*; |
3 | | -import java.security.*; |
4 | | -import java.text.*; |
5 | | -import java.util.*; |
6 | | -import java.util.concurrent.*; |
7 | | -import java.util.function.*; |
8 | | -import java.util.regex.*; |
9 | | -import java.util.stream.*; |
10 | | -import static java.util.stream.Collectors.joining; |
11 | | -import static java.util.stream.Collectors.toList; |
12 | | - |
13 | | -class Result { |
14 | | - public static List<Integer> shortestReach(int n, List<List<Integer>> edges, int s) { |
15 | | - // Your code here |
16 | | - return null; |
17 | | - } |
18 | | - |
19 | | -} |
20 | | - |
21 | | -class InputReader { |
22 | | - |
23 | | - private InputStream stream; |
24 | | - private byte[] buf = new byte[1024]; |
25 | | - private int curChar; |
26 | | - private int numChars; |
27 | | - private SpaceCharFilter filter; |
28 | | - |
29 | | - public InputReader(InputStream stream) { |
30 | | - this.stream = stream; |
31 | | - } |
32 | | - |
33 | | - public int read() { |
34 | | - if (numChars == -1) |
35 | | - throw new InputMismatchException(); |
36 | | - if (curChar >= numChars) { |
37 | | - curChar = 0; |
38 | | - try { |
39 | | - numChars = stream.read(buf); |
40 | | - } catch (IOException e) { |
41 | | - throw new InputMismatchException(); |
42 | | - } |
43 | | - if (numChars <= 0) |
44 | | - return -1; |
45 | | - } |
46 | | - return buf[curChar++]; |
47 | | - } |
48 | | - |
49 | | - public int readInt() { |
50 | | - int c = read(); |
51 | | - while (isSpaceChar(c)) |
52 | | - c = read(); |
53 | | - int sgn = 1; |
54 | | - if (c == '-') { |
55 | | - sgn = -1; |
56 | | - c = read(); |
57 | | - } |
58 | | - int res = 0; |
59 | | - do { |
60 | | - if (c < '0' || c > '9') |
61 | | - throw new InputMismatchException(); |
62 | | - res *= 10; |
63 | | - res += c - '0'; |
64 | | - c = read(); |
65 | | - } while (!isSpaceChar(c)); |
66 | | - return res * sgn; |
67 | | - } |
68 | | - |
69 | | - public String readString() { |
70 | | - int c = read(); |
71 | | - while (isSpaceChar(c)) |
72 | | - c = read(); |
73 | | - StringBuilder res = new StringBuilder(); |
74 | | - do { |
75 | | - res.appendCodePoint(c); |
76 | | - c = read(); |
77 | | - } while (!isSpaceChar(c)); |
78 | | - return res.toString(); |
79 | | - } |
80 | | - |
81 | | - public boolean isSpaceChar(int c) { |
82 | | - if (filter != null) |
83 | | - return filter.isSpaceChar(c); |
84 | | - return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; |
85 | | - } |
86 | | - |
87 | | - public String next() { |
88 | | - return readString(); |
89 | | - } |
90 | | - |
91 | | - public interface SpaceCharFilter { |
92 | | - public boolean isSpaceChar(int ch); |
93 | | - } |
94 | | -} |
95 | | - |
96 | | -class OutputWriter { |
97 | | - private final PrintWriter writer; |
98 | | - |
99 | | - public OutputWriter(OutputStream outputStream) { |
100 | | - writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); |
101 | | - } |
102 | | - |
103 | | - public OutputWriter(Writer writer) { |
104 | | - this.writer = new PrintWriter(writer); |
105 | | - } |
106 | | - |
107 | | - public void print(Object... objects) { |
108 | | - for (int i = 0; i < objects.length; i++) { |
109 | | - if (i != 0) |
110 | | - writer.print(' '); |
111 | | - writer.print(objects[i]); |
112 | | - } |
113 | | - } |
114 | | - |
115 | | - public void printLine(Object... objects) { |
116 | | - print(objects); |
117 | | - writer.println(); |
118 | | - } |
119 | | - |
120 | | - public void close() { |
121 | | - writer.close(); |
122 | | - } |
123 | | - |
124 | | - public void flush() { |
125 | | - writer.flush(); |
126 | | - } |
127 | | - |
128 | | -} |
129 | | - |
130 | | -class IOUtils { |
131 | | - public static int[] readIntArray(InputReader in, int size) { |
132 | | - int[] array = new int[size]; |
133 | | - for (int i = 0; i < size; i++) |
134 | | - array[i] = in.readInt(); |
135 | | - return array; |
136 | | - } |
137 | | - |
138 | | -} |
139 | | - |
140 | | -public class Solution { |
141 | | - public static void main(String[] args) { |
142 | | - InputReader in = new InputReader(System.in); |
143 | | - OutputWriter out = new OutputWriter(System.out); |
144 | | - |
145 | | - int t = in.readInt(); |
146 | | - while (t > 0) { |
147 | | - int n = in.readInt(); |
148 | | - int m = in.readInt(); |
149 | | - List<List<Integer>> edges = new ArrayList<>(); |
150 | | - for (int i = 0; i < m; i++) { |
151 | | - List<Integer> e = new ArrayList<>(); |
152 | | - e.add(in.readInt()); |
153 | | - e.add(in.readInt()); |
154 | | - e.add(in.readInt()); |
155 | | - edges.add(e); |
156 | | - } |
157 | | - int start = in.readInt(); |
158 | | - var result = Result.shortestReach(n, edges, start); |
159 | | - for (Integer integer : result) { |
160 | | - out.print(integer + " "); |
161 | | - } |
162 | | - out.printLine(); |
163 | | - t--; |
164 | | - } |
165 | | - out.flush(); |
166 | | - out.close(); |
167 | | - } |
168 | | -} |
| 1 | +// import java.io.*; |
| 2 | +// import java.math.*; |
| 3 | +// import java.security.*; |
| 4 | +// import java.text.*; |
| 5 | +// import java.util.*; |
| 6 | +// import java.util.concurrent.*; |
| 7 | +// import java.util.function.*; |
| 8 | +// import java.util.regex.*; |
| 9 | +// import java.util.stream.*; |
| 10 | +// import static java.util.stream.Collectors.joining; |
| 11 | +// import static java.util.stream.Collectors.toList; |
| 12 | + |
| 13 | +// class Result { |
| 14 | +// public static List<Integer> shortestReach(int n, List<List<Integer>> edges, int s) { |
| 15 | +// // Your code here |
| 16 | +// return null; |
| 17 | +// } |
| 18 | + |
| 19 | +// } |
| 20 | + |
| 21 | +// class InputReader { |
| 22 | + |
| 23 | +// private InputStream stream; |
| 24 | +// private byte[] buf = new byte[1024]; |
| 25 | +// private int curChar; |
| 26 | +// private int numChars; |
| 27 | +// private SpaceCharFilter filter; |
| 28 | + |
| 29 | +// public InputReader(InputStream stream) { |
| 30 | +// this.stream = stream; |
| 31 | +// } |
| 32 | + |
| 33 | +// public int read() { |
| 34 | +// if (numChars == -1) |
| 35 | +// throw new InputMismatchException(); |
| 36 | +// if (curChar >= numChars) { |
| 37 | +// curChar = 0; |
| 38 | +// try { |
| 39 | +// numChars = stream.read(buf); |
| 40 | +// } catch (IOException e) { |
| 41 | +// throw new InputMismatchException(); |
| 42 | +// } |
| 43 | +// if (numChars <= 0) |
| 44 | +// return -1; |
| 45 | +// } |
| 46 | +// return buf[curChar++]; |
| 47 | +// } |
| 48 | + |
| 49 | +// public int readInt() { |
| 50 | +// int c = read(); |
| 51 | +// while (isSpaceChar(c)) |
| 52 | +// c = read(); |
| 53 | +// int sgn = 1; |
| 54 | +// if (c == '-') { |
| 55 | +// sgn = -1; |
| 56 | +// c = read(); |
| 57 | +// } |
| 58 | +// int res = 0; |
| 59 | +// do { |
| 60 | +// if (c < '0' || c > '9') |
| 61 | +// throw new InputMismatchException(); |
| 62 | +// res *= 10; |
| 63 | +// res += c - '0'; |
| 64 | +// c = read(); |
| 65 | +// } while (!isSpaceChar(c)); |
| 66 | +// return res * sgn; |
| 67 | +// } |
| 68 | + |
| 69 | +// public String readString() { |
| 70 | +// int c = read(); |
| 71 | +// while (isSpaceChar(c)) |
| 72 | +// c = read(); |
| 73 | +// StringBuilder res = new StringBuilder(); |
| 74 | +// do { |
| 75 | +// res.appendCodePoint(c); |
| 76 | +// c = read(); |
| 77 | +// } while (!isSpaceChar(c)); |
| 78 | +// return res.toString(); |
| 79 | +// } |
| 80 | + |
| 81 | +// public boolean isSpaceChar(int c) { |
| 82 | +// if (filter != null) |
| 83 | +// return filter.isSpaceChar(c); |
| 84 | +// return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1; |
| 85 | +// } |
| 86 | + |
| 87 | +// public String next() { |
| 88 | +// return readString(); |
| 89 | +// } |
| 90 | + |
| 91 | +// public interface SpaceCharFilter { |
| 92 | +// public boolean isSpaceChar(int ch); |
| 93 | +// } |
| 94 | +// } |
| 95 | + |
| 96 | +// class OutputWriter { |
| 97 | +// private final PrintWriter writer; |
| 98 | + |
| 99 | +// public OutputWriter(OutputStream outputStream) { |
| 100 | +// writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream))); |
| 101 | +// } |
| 102 | + |
| 103 | +// public OutputWriter(Writer writer) { |
| 104 | +// this.writer = new PrintWriter(writer); |
| 105 | +// } |
| 106 | + |
| 107 | +// public void print(Object... objects) { |
| 108 | +// for (int i = 0; i < objects.length; i++) { |
| 109 | +// if (i != 0) |
| 110 | +// writer.print(' '); |
| 111 | +// writer.print(objects[i]); |
| 112 | +// } |
| 113 | +// } |
| 114 | + |
| 115 | +// public void printLine(Object... objects) { |
| 116 | +// print(objects); |
| 117 | +// writer.println(); |
| 118 | +// } |
| 119 | + |
| 120 | +// public void close() { |
| 121 | +// writer.close(); |
| 122 | +// } |
| 123 | + |
| 124 | +// public void flush() { |
| 125 | +// writer.flush(); |
| 126 | +// } |
| 127 | + |
| 128 | +// } |
| 129 | + |
| 130 | +// class IOUtils { |
| 131 | +// public static int[] readIntArray(InputReader in, int size) { |
| 132 | +// int[] array = new int[size]; |
| 133 | +// for (int i = 0; i < size; i++) |
| 134 | +// array[i] = in.readInt(); |
| 135 | +// return array; |
| 136 | +// } |
| 137 | + |
| 138 | +// } |
| 139 | + |
| 140 | +// public class Solution { |
| 141 | +// public static void main(String[] args) { |
| 142 | +// InputReader in = new InputReader(System.in); |
| 143 | +// OutputWriter out = new OutputWriter(System.out); |
| 144 | + |
| 145 | +// int t = in.readInt(); |
| 146 | +// while (t > 0) { |
| 147 | +// int n = in.readInt(); |
| 148 | +// int m = in.readInt(); |
| 149 | +// List<List<Integer>> edges = new ArrayList<>(); |
| 150 | +// for (int i = 0; i < m; i++) { |
| 151 | +// List<Integer> e = new ArrayList<>(); |
| 152 | +// e.add(in.readInt()); |
| 153 | +// e.add(in.readInt()); |
| 154 | +// e.add(in.readInt()); |
| 155 | +// edges.add(e); |
| 156 | +// } |
| 157 | +// int start = in.readInt(); |
| 158 | +// var result = Result.shortestReach(n, edges, start); |
| 159 | +// for (Integer integer : result) { |
| 160 | +// out.print(integer + " "); |
| 161 | +// } |
| 162 | +// out.printLine(); |
| 163 | +// t--; |
| 164 | +// } |
| 165 | +// out.flush(); |
| 166 | +// out.close(); |
| 167 | +// } |
| 168 | +// } |
0 commit comments