git reimport

This commit is contained in:
2019-03-15 13:47:54 +04:00
commit 3b461f73de
489 changed files with 1631603 additions and 0 deletions

View File

@@ -0,0 +1,108 @@
package chelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import io.InputReader;
import io.OutputWriter;
import solutions.ChelperSolution;
public class D extends ChelperSolution {
@Override
public void solve(int testNumber, InputReader in, OutputWriter out) {
super.solve(testNumber, in, out);
}
boolean[] merge(boolean[] a, boolean[] b) {
int n = a.length;
int m = b.length;
boolean[] c = new boolean[n + m + 2];
c[0] = true;
for (int i = 0; i < n; i++) {
c[1 + i] = a[i];
}
c[n + 1] = false;
for (int i = 0; i < m; i++) {
c[n + 2 + i] = b[i];
}
return c;
}
public static final int N = 11;
public void rawPrint(boolean[] a) {
// for (boolean i : a) {
// out.print(i ? '(' : ')');
// }
// out.println();
for (boolean i : a) {
System.out.write(i ? '(' : ')');
}
System.out.write('\n');
}
@Override
public void solve(int testNumber) {
List<List<boolean[]>> dp = new ArrayList<>();
for (int i = 0; i <= N; i++) {
dp.add(new ArrayList<>());
}
dp.get(0).add(new boolean[0]);
for (int i = 1; i <= N; i++) {
for (int l1 = 0; l1 <= i - 1; l1++) {
int l2 = i - 1 - l1;
List<boolean[]> dp1 = dp.get(l1);
List<boolean[]> dp2 = dp.get(l2);
for (boolean[] a : dp1) {
for (boolean[] b : dp2) {
dp.get(i).add(merge(a, b));
}
}
}
}
for (int i = 0; i <= N; i++) {
Collections.sort(dp.get(i), new Comparator<boolean[]>() {
@Override
public int compare(boolean[] o1, boolean[] o2) {
for (int i = 0; i < o1.length; i++) {
if (o1[i] && !o2[i]) {
return -1;
}
if (!o1[i] && o2[i]) {
return 1;
}
}
return 0;
}
});
// out.println(i + ":");
// out.println(dp.get(i).size());
// for (boolean[] a : dp.get(i)) {
// rawPrint(a);
// }
}
int n = in.nextInt();
for (boolean[] b : dp.get(n)) {
rawPrint(b);
}
System.out.flush();
}
}

View File

@@ -0,0 +1,39 @@
{
"name" : "D",
"testType" : "SINGLE",
"input" : {
"type" : "STANDARD",
"fileName" : "input.txt"
},
"output" : {
"type" : "STANDARD",
"fileName" : "output.txt"
},
"tests" : [ {
"input" : "2",
"output" : "(())\n()()",
"index" : 0,
"active" : true
}, {
"input" : "3",
"output" : "((()))\n(()())\n(())()\n()(())\n()()()",
"index" : 1,
"active" : true
} ],
"location" : "src/chelper",
"vmArgs" : "-Xmx256m -Xss64m",
"mainClass" : "Main",
"taskClass" : "chelper.D",
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
"checkerParameters" : "",
"testClasses" : [ ],
"date" : "2019.03.15",
"contestName" : "Yandex.Interview",
"truncate" : true,
"inputClass" : "io.InputReader",
"outputClass" : "io.OutputWriter",
"includeLocale" : false,
"failOnOverflow" : false,
"interactive" : false,
"interactor" : "net.egork.chelper.tester.Interactor"
}

View File

@@ -0,0 +1,74 @@
package chelper;
import java.io.IOException;
import io.InputReader;
import io.OutputWriter;
import solutions.ChelperSolution;
public class F extends ChelperSolution {
@Override
public void solve(int testNumber, InputReader in, OutputWriter out) {
super.solve(testNumber, in, out);
}
int rawReadInt() {
try {
int res = 0;
while (true) {
char c = (char) System.in.read();
if ('0' <= c && c <= '9') {
res = res * 10 + c - '0';
} else {
return res;
}
}
} catch (IOException e) {
throw new RuntimeException(e);
}
}
int maxDecimalPower(int x) {
int d = 1;
while (d * 10 <= x) {
d *= 10;
}
return d;
}
void rawPrintSpace(int x) {
int d = maxDecimalPower(x);
while (d > 0) {
System.out.write(x / d % 10 + '0');
d /= 10;
}
System.out.write(' ');
}
@Override
public void solve(int testNumber) {
int[] counts = new int[101];
int k = rawReadInt();
int c = 0;
for (int i = 0; i < k; i++) {
int m = rawReadInt();
for (int j = 0; j < m; j++) {
counts[rawReadInt()]++;
}
}
for (int i = 0; i < 101; i++) {
for (int j = 0; j < counts[i]; j++) {
rawPrintSpace(i);
}
}
}
}

View File

@@ -0,0 +1,38 @@
{
"name" : "F",
"testType" : "SINGLE",
"input" : {
"type" : "STANDARD",
"fileName" : "input.txt"
},
"output" : {
"type" : "STANDARD",
"fileName" : "output.txt"
},
"tests" : [ {
"input" : "4\n6 2 26 64 88 96 96\n4 8 20 65 86\n7 1 4 16 42 58 61 69\n1 84",
"output" : "1 2 4 8 16 20 26 42\n58 61 64 65 69 84 86\n88 96 96 ",
"index" : 0,
"active" : false
}, {
"input" : "",
"index" : 1,
"active" : true
} ],
"location" : "src/chelper",
"vmArgs" : "-Xmx256m -Xss64m",
"mainClass" : "Main",
"taskClass" : "chelper.F",
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
"checkerParameters" : "",
"testClasses" : [ ],
"date" : "2019.03.15",
"contestName" : "Yandex.Interview",
"truncate" : true,
"inputClass" : "io.InputReader",
"outputClass" : "io.OutputWriter",
"includeLocale" : false,
"failOnOverflow" : false,
"interactive" : false,
"interactor" : "net.egork.chelper.tester.Interactor"
}