git reimport
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskC extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
int[] a = in.nextIntArray(n);
|
||||
|
||||
int[] counts = new int[200];
|
||||
for (int i : a) {
|
||||
counts[i]++;
|
||||
}
|
||||
|
||||
int size1 = 0;
|
||||
int size2 = 0;
|
||||
int size3Plus = 0;
|
||||
|
||||
for (int count : counts) {
|
||||
if (count == 1) {
|
||||
size1++;
|
||||
}
|
||||
if (count == 2) {
|
||||
size2++;
|
||||
}
|
||||
if (count >= 3) {
|
||||
size3Plus++;
|
||||
}
|
||||
}
|
||||
|
||||
if (size1 % 2 == 1 && size3Plus == 0) {
|
||||
out.println("NO");
|
||||
return;
|
||||
}
|
||||
|
||||
boolean[] mask = new boolean[n];
|
||||
|
||||
boolean parity = true;
|
||||
boolean shouldUse3Plus = size1 % 2 == 1;
|
||||
|
||||
for (int i = 0; i < 200; i++) {
|
||||
if (counts[i] == 1) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (a[j] == i) {
|
||||
mask[j] = parity;
|
||||
}
|
||||
}
|
||||
|
||||
parity = !parity;
|
||||
}
|
||||
|
||||
if (counts[i] >= 3 && shouldUse3Plus) {
|
||||
boolean first = true;
|
||||
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (a[j] == i) {
|
||||
mask[j] = parity == first;
|
||||
first = false;
|
||||
}
|
||||
}
|
||||
|
||||
parity = !parity;
|
||||
shouldUse3Plus = false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
out.println("YES");
|
||||
for (boolean b : mask) {
|
||||
out.print(b ? 'A' : 'B');
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user