MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / main

Method main

src/class201/Code05_OTOCI1.java:162–199  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

160 }
161
162 public static void main(String[] args) throws Exception {
163 FastReader in = new FastReader(System.in);
164 PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
165 n = in.nextInt();
166 for (int i = 1; i <= n; i++) {
167 arr[i] = in.nextInt();
168 sum[i] = arr[i];
169 }
170 m = in.nextInt();
171 String op;
172 int x, y;
173 for (int i = 1; i <= m; i++) {
174 op = in.nextString();
175 x = in.nextInt();
176 y = in.nextInt();
177 if (op.equals("bridge")) {
178 if (findroot(x) == findroot(y)) {
179 out.println("no");
180 } else {
181 out.println("yes");
182 link(x, y);
183 }
184 } else if (op.equals("penguins")) {
185 splay(x);
186 arr[x] = y;
187 up(x);
188 } else {
189 if (findroot(x) != findroot(y)) {
190 out.println("impossible");
191 } else {
192 split(x, y);
193 out.println(sum[y]);
194 }
195 }
196 }
197 out.flush();
198 out.close();
199 }
200
201 // 读写工具类
202 static class FastReader {

Callers

nothing calls this directly

Calls 11

nextIntMethod · 0.95
nextStringMethod · 0.95
findrootMethod · 0.95
linkMethod · 0.95
splayMethod · 0.95
upMethod · 0.95
splitMethod · 0.95
equalsMethod · 0.80
printlnMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected