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,155 @@
package chelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class Brute extends SimpleSavingChelperSolution {
private int condCount;
private List<List<List<Integer>>> X;
private List<List<Long>> multipliers;
private List<Long> consts;
private long[] values;
private boolean[] set;
private int[] termCounts;
private int[] bruteOrder;
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
long minValue = 33;
long maxValue = 126;
@Override
public void solve(int testNumber) {
condCount = in.nextInt();
X = new ArrayList<>();
multipliers = new ArrayList<>();
consts = new ArrayList<>();
set = new boolean[condCount];
values = new long[condCount];
termCounts = new int[condCount];
for (int i = 0; i < condCount; i++) {
X.add(new ArrayList<>());
multipliers.add(new ArrayList<>());
termCounts[i] = in.nextInt();
for (int j = 0; j < termCounts[i]; j++) {
int multCount = in.nextInt();
X.get(i).add(new ArrayList<>());
for (int k = 0; k < multCount; k++) {
int mult = in.nextInt();
X.get(i).get(j).add(mult);
}
}
for (int j = 0; j < termCounts[i]; j++) {
multipliers.get(i).add(in.nextLong());
}
consts.add(in.nextLong());
}
bruteOrder = in.nextIntArray(condCount);
System.out.println("test");
for (int i = 0; i < condCount; i++) {
System.out.printf(
"%12d %12d %12d\n",
estimate(i, false), consts.get(i), estimate(i, true));
}
System.out.println(okEstimates());
brute(0);
}
long estimate(int cond, boolean max) {
long res = 0;
for (int i = 0; i < termCounts[cond]; i++) {
long term = 1;
long m = multipliers.get(cond).get(i);
boolean localMax = max == m > 0;
for (int x : X.get(cond).get(i)) {
if (set[x]) {
term *= values[x];
} else {
if (localMax) {
term *= maxValue;
} else {
term *= minValue;
}
}
}
res += term * m;
}
return res;
}
boolean okEstimates() {
for (int cond = 0; cond < condCount; cond++) {
long min = estimate(cond, false);
long max = estimate(cond, true);
if (min > consts.get(cond) || max < consts.get(cond)) {
// System.out.println("bad " + cond);
return false;
}
}
return true;
}
long iters = 0;
void brute(int depth) {
if (depth >= condCount) {
System.out.println("Found " + Arrays.toString(values));
System.out.flush();
return;
}
int var = bruteOrder[depth];
for (long value = minValue; value <= maxValue; value++) {
values[var] = value;
set[var] = true;
if (okEstimates()) {
iters++;
if (iters % 10000 == 0) {
System.out.printf("iter = %10d\n", iters);
System.out.printf("depth = %5d\n", depth);
System.out.print("i = ");
for (int i : bruteOrder) {
System.out.printf("%3d ", i);
}
System.out.println();
System.out.print("a = ");
for (int i : bruteOrder) {
System.out.printf("%3d ", values[i]);
}
System.out.println();
System.out.flush();
}
brute(depth + 1);
}
set[var] = false;
}
}
}

View File

@@ -0,0 +1,420 @@
5 Brute
6 SINGLE
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
1
0
2750 40
8
1 38
1 12
1 30
1 18
1 23
1 16
2 2 24
1 11
1 1 -1 -1 -1 -1 -1 1
-9009
8
1 9
1 28
1 35
1 17
1 27
1 27
3 19 19 23
1 21
1 1 -1 -1 -1 1 -1 1
-580705
7
1 26
1 24
1 14
2 29 32
2 12 19
2 5 11
1 31
1 -1 -125 1 -1 -1 1
-19297
6
1 19
1 27
1 9
1 11
2 30 33
3 0 1 12
1 1 1 1 -1 67
8858058
8
1 13
1 13
1 16
2 3 24
1 20
2 14 36
1 33
1 22
1 -1 1 -1 1 1 -1 1
-4973
7
1 15
1 21
1 3
2 13 26
1 21
1 22
4 22 28 30 39
1 -1 1 1 1 -1 -1
-12805567
7
1 5
1 8
1 4
1 9
1 30
4 0 7 14 15
1 35
1 1 1 -1 1 -1 -1
-27732588
7
1 38
1 33
1 6
1 35
3 0 11 29
1 16
1 29
-1 -1 1 1 1 1 1
257196
7
1 24
1 7
2 31 39
1 5
1 20
1 14
1 33
1 1 84 1 1 1 -1
490112
4
2 4 10
2 1 22
1 25
3 0 13 19
1 -70 -125 -88
-34045542
5
1 28
1 31
2 0 30
1 27
2 3 4
1 -8610 1 -1 1
-938912
8
2 4 8
1 27
2 24 29
1 6
1 22
1 26
2 0 5
1 34
1 -1 1 -1 -1 -1 -1 -1
7589
9
1 33
1 20
1 34
1 12
1 33
2 6 28
1 27
1 16
1 5
1 1 -1 -1 -1 1 -1 1 1
11473
7
1 1
2 1 16
1 15
1 32
1 36
2 22 27
2 15 20
1 1 -1 -1 1 1 1
13944
5
1 17
2 0 10
1 24
2 13 33
1 23
1 1 -1 4900 1
37520490
7
1 38
2 27 34
1 1
1 4
1 32
2 3 21
1 32
1 -1 1 -1 1 -1 -1
-23809
9
1 18
2 10 20
1 8
1 4
1 10
1 19
1 18
1 2
1 34
1 73 1 1 -1 -1 1 -1 -1
832009
7
1 24
1 0
1 16
1 1
1 34
1 3
1 11
-1 1 84 -1 1 -1 -1
4318
7
1 15
1 26
1 10
1 5
2 14 33
1 24
1 17
1 -84 125 1 -1 -1 1
-2401
8
1 4
1 24
1 12
2 5 15
2 1 26
1 18
1 36
1 12
1 1 -1 -1 70 -1 1 -1
165790
9
1 14
2 7 9
1 16
1 19
1 12
1 27
1 33
1 20
1 11
1 1 -1 -1 -1 -1 70 -1 -1
12685
5
1 33
2 18 28
1 6
4 1 5 7 12
1 35
1 1 -1 1 -1
26088083
7
1 34
1 9
1 16
2 24 32
1 30
2 17 31
2 8 37
1 -1 1 1 1 -1 -1
-14712
6
2 12 24
2 26 28
3 3 17 26
1 10
1 10
1 18
1 1 -1 -1 -1 1
-518496
8
1 27
2 16 38
1 36
1 16
1 10
1 31
1 32
1 1
1 1 -1 -1 1 70 -84 -1
9479
6
1 18
2 7 37
1 38
2 12 37
1 39
2 22 35
1 1 1 1 -1 -1
13529
5
1 22
1 31
1 20
2 3 24
4 3 11 16 26
1 -1 -1 123 -73
-1052607271
8
1 15
1 38
1 1
1 36
1 4
1 13
1 17
2 25 36
1 -1 -1 84 -1 1 -1 -1
-1076
6
1 23
1 31
2 6 25
1 27
1 1
1 9
67 70 1 1 -1 -1
23277
5
2 27 32
2 26 36
4 2 22 22 24
1 17
1 7
1 -1 -1 1 1
-25347227
8
1 31
1 29
1 38
1 3
1 29
1 15
1 14
2 8 12
1 -73 1 -1 1 1 1 1
-2380
7
2 6 17
1 29
1 7
1 13
1 38
1 22
1 29
1 -1 -1 1 1 -125 125
17233
9
1 7
1 18
1 34
1 0
1 17
1 15
1 20
1 31
1 11
1 1 -70 1 1 1 1 1 1
-7375
5
2 14 32
2 9 38
1 14
2 10 38
2 21 35
123 -1 1 -1 1
689844
6
1 4
1 17
3 3 8 33
1 28
2 16 20
1 13
1 -1 -1 -1 125 1
-424956
4
2 31 32
2 0 4
3 27 32 37
2 18 25
1 1 1 125
1365356
6
1 14
1 13
3 7 35 35
1 26
1 38
2 11 36
123 1 -1 -1 1 -1
-245866
7
3 17 27 39
1 26
1 3
1 26
2 27 38
1 32
1 22
1 -1 -86 -1 1 -1 -1
603387
8
1 9
1 17
1 32
1 39
1 30
1 19
1 28
1 21
1 -1 -1 1 -1 -1 1 1
-11
8
2 8 31
2 16 19
1 35
1 37
1 18
1 9
1 25
1 7
1 1 1 -1 1 -1 -1 -1
15035
2 22 24 3 11 16 26 1 5 7 12 0 14 15 28 30 39 17 27 35 32 37 8 33 13 19 29 23 31 38 36 18 25 4 20 21 10 9 6 34
-1
1
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
13 chelper.Brute
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2017.10.18
0
1
14 io.InputReader
15 io.OutputWriter
0
0