git reimport
This commit is contained in:
39
archive/2016.08/2016.08.27 - unsorted/Hanoi.java
Normal file
39
archive/2016.08/2016.08.27 - unsorted/Hanoi.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class Hanoi {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int[] a = new int[n];
|
||||
|
||||
String s = in.nextString();
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i] = s.charAt(i) - 'A';
|
||||
}
|
||||
|
||||
for (int i = n - 1; i >= 0; i--) {
|
||||
if (a[i] == 2) {
|
||||
out.println("NO");
|
||||
return;
|
||||
}
|
||||
|
||||
if (a[i] == 1) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (a[j] < 2) {
|
||||
a[j] = (1 + a[j]) % 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (a[j] > 1) {
|
||||
a[j] = 1 + a[j] % 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.println("YES");
|
||||
}
|
||||
}
|
21
archive/2016.08/2016.08.27 - unsorted/Hanoi.task
Normal file
21
archive/2016.08/2016.08.27 - unsorted/Hanoi.task
Normal file
@@ -0,0 +1,21 @@
|
||||
5 Hanoi
|
||||
6 SINGLE
|
||||
6 CUSTOM
|
||||
9 input.txt
|
||||
6 CUSTOM
|
||||
10 output.txt
|
||||
0
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.Hanoi
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.27
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
Reference in New Issue
Block a user