git reimport
This commit is contained in:
39
archive/2018.03/2018.03.18 - unsorted/CGen.java
Normal file
39
archive/2018.03/2018.03.18 - unsorted/CGen.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class CGen extends SimpleSavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int t = 20;
|
||||
out.println(t);
|
||||
Random random = new Random();
|
||||
|
||||
for (int i = 0; i < t; i++) {
|
||||
int l = 20000;
|
||||
int n = 100000;
|
||||
int wl = 5;
|
||||
|
||||
out.println(l);
|
||||
for (int j = 0; j < l; j++) {
|
||||
for (int k = 0; k < wl; k++) {
|
||||
out.print((char)(random.nextInt(26) + 97));
|
||||
}
|
||||
out.print(' ');
|
||||
}
|
||||
out.println();
|
||||
|
||||
out.println("a a 50 1 1 1 30");
|
||||
}
|
||||
}
|
||||
}
|
25
archive/2018.03/2018.03.18 - unsorted/CGen.task
Normal file
25
archive/2018.03/2018.03.18 - unsorted/CGen.task
Normal file
@@ -0,0 +1,25 @@
|
||||
4 CGen
|
||||
12 MULTI_NUMBER
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
1 1
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
12 chelper.CGen
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2018.03.18
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
87
archive/2018.03/2018.03.18 - unsorted/TaskA.java
Normal file
87
archive/2018.03/2018.03.18 - unsorted/TaskA.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.GCJSolution;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskA extends GCJSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
int M = 20;
|
||||
|
||||
int[] explode(long x) {
|
||||
int[] digits = new int[M];
|
||||
|
||||
for (int i = M - 1; i >= 0; i--) {
|
||||
digits[i] = (int) (x % 10);
|
||||
x /= 10;
|
||||
}
|
||||
|
||||
return digits;
|
||||
}
|
||||
|
||||
long combine(int[] digits) {
|
||||
long x = 0;
|
||||
|
||||
for (int i = 0; i < M; i++) {
|
||||
x *= 10;
|
||||
x += digits[i];
|
||||
}
|
||||
|
||||
return x;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
long x = in.nextLong();
|
||||
|
||||
int[] digits = explode(x);
|
||||
|
||||
int[] digitsDown = Arrays.copyOf(digits, M);
|
||||
for (int i = 0; i < M; i++) {
|
||||
if (digitsDown[i] % 2 == 1) {
|
||||
digitsDown[i]--;
|
||||
|
||||
for (int j = i + 1; j < M; j++) {
|
||||
digitsDown[j] = 8;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int[] digitsUp = Arrays.copyOf(digits, M);
|
||||
for (int i = 0; i < M; i++) {
|
||||
if (digitsUp[i] % 2 == 1) {
|
||||
digitsUp[i]++;
|
||||
|
||||
for (int j = i; j >= 0; j--) {
|
||||
if (digitsUp[j] >= 10) {
|
||||
digitsUp[j - 1]++;
|
||||
digitsUp[j] -= 10;
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = i + 1; j < M; j++) {
|
||||
digitsUp[j] = 0;
|
||||
}
|
||||
|
||||
i = -1;
|
||||
}
|
||||
}
|
||||
|
||||
long a = combine(digitsUp);
|
||||
long b = combine(digitsDown);
|
||||
|
||||
debug.println(a);
|
||||
debug.println(b);
|
||||
|
||||
out.println(Math.min(a - x, x - b));
|
||||
}
|
||||
}
|
247
archive/2018.03/2018.03.18 - unsorted/TaskA.task
Normal file
247
archive/2018.03/2018.03.18 - unsorted/TaskA.task
Normal file
@@ -0,0 +1,247 @@
|
||||
5 TaskA
|
||||
12 MULTI_NUMBER
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
4
|
||||
0
|
||||
14 4
|
||||
42
|
||||
11
|
||||
1
|
||||
2018
|
||||
43 Case #1: 0
|
||||
Case #2: 3
|
||||
Case #3: 1
|
||||
Case #4: 2
|
||||
1
|
||||
1
|
||||
6 1
|
||||
1999
|
||||
10 Case #1: 1
|
||||
1
|
||||
2
|
||||
550 100
|
||||
42
|
||||
11
|
||||
1
|
||||
2018
|
||||
27185
|
||||
14639
|
||||
52210
|
||||
44277
|
||||
37874
|
||||
87723
|
||||
25712
|
||||
15390
|
||||
4
|
||||
99999
|
||||
93854
|
||||
85917
|
||||
79503
|
||||
68743
|
||||
2280
|
||||
93146
|
||||
12045
|
||||
67479
|
||||
66732
|
||||
2
|
||||
34797
|
||||
93552
|
||||
92138
|
||||
44755
|
||||
71398
|
||||
89060
|
||||
32223
|
||||
26728
|
||||
39215
|
||||
37926
|
||||
35071
|
||||
82170
|
||||
8594
|
||||
33915
|
||||
51676
|
||||
91698
|
||||
3
|
||||
53938
|
||||
30027
|
||||
39726
|
||||
7050
|
||||
48355
|
||||
16082
|
||||
37501
|
||||
100000
|
||||
30327
|
||||
71689
|
||||
45911
|
||||
24896
|
||||
20710
|
||||
51229
|
||||
51735
|
||||
17431
|
||||
13313
|
||||
37375
|
||||
89694
|
||||
36355
|
||||
9
|
||||
82067
|
||||
55337
|
||||
48011
|
||||
34577
|
||||
17099
|
||||
12318
|
||||
97239
|
||||
10
|
||||
22043
|
||||
63947
|
||||
8
|
||||
5
|
||||
71055
|
||||
77071
|
||||
12936
|
||||
99899
|
||||
45308
|
||||
3457
|
||||
864
|
||||
84926
|
||||
44281
|
||||
7
|
||||
24112
|
||||
95
|
||||
72004
|
||||
62720
|
||||
86550
|
||||
57351
|
||||
80329
|
||||
71084
|
||||
13007
|
||||
6
|
||||
74530
|
||||
57495
|
||||
30796
|
||||
16943
|
||||
28443
|
||||
68025
|
||||
|
||||
-1
|
||||
1
|
||||
3
|
||||
1491 100
|
||||
42
|
||||
11
|
||||
1
|
||||
2018
|
||||
5758020093496408
|
||||
9613792347426885
|
||||
3967875361173446
|
||||
9867172022380909
|
||||
2322182873496790
|
||||
7155037038493018
|
||||
6292108915390535
|
||||
9915597146393065
|
||||
8466052891810652
|
||||
1674063778837369
|
||||
7321621179282844
|
||||
8253307385919314
|
||||
3567184769588921
|
||||
6847661393112648
|
||||
3357991438513382
|
||||
9999999999999999
|
||||
10
|
||||
3562012847348354
|
||||
2688526581668833
|
||||
72626903459071
|
||||
7414703459320991
|
||||
9138712171425931
|
||||
1028228115669668
|
||||
2629949406666875
|
||||
3104520762284013
|
||||
2
|
||||
7708830672020092
|
||||
5796593353750626
|
||||
9297554078123485
|
||||
960622099409772
|
||||
3873256332372029
|
||||
95
|
||||
7148683241469127
|
||||
1555555555555555
|
||||
1145021543961538
|
||||
9
|
||||
5744157705728287
|
||||
8224467715526306
|
||||
2018414818516939
|
||||
706312858381499
|
||||
7012372595063895
|
||||
6919189502961077
|
||||
4209543970942302
|
||||
298697545201486
|
||||
4567201960896214
|
||||
3704054990284398
|
||||
8339185755560936
|
||||
2408503546020309
|
||||
1334558720370991
|
||||
5868260286332867
|
||||
1813912067313008
|
||||
8025733079180372
|
||||
6
|
||||
6211100873553101
|
||||
8872869631451669
|
||||
6546228537805069
|
||||
1234630672613174
|
||||
8
|
||||
2332364268072483
|
||||
8028340381799060
|
||||
8836995978058525
|
||||
8054059509475589
|
||||
8052156782485492
|
||||
6875010548968352
|
||||
4431794000968698
|
||||
594990990113090
|
||||
4
|
||||
504766857313058
|
||||
890840490907714
|
||||
2438060574218610
|
||||
26625097658661
|
||||
799217944072069
|
||||
4972289917720162
|
||||
3481163110028389
|
||||
8888888888888889
|
||||
7496421069556640
|
||||
8162652986612537
|
||||
5315833303057231
|
||||
10000000000000000
|
||||
9628411809013884
|
||||
4377715834626225
|
||||
9326168643369068
|
||||
5205989817709523
|
||||
4193581220065955
|
||||
8638923878146261
|
||||
2862778229643431
|
||||
6907973096512503
|
||||
5
|
||||
3
|
||||
4565036839533787
|
||||
1408672413047582
|
||||
2543296985726139
|
||||
8379993013302636
|
||||
5575771732789526
|
||||
7
|
||||
4900575755354680
|
||||
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskA
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2018.03.18
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
52
archive/2018.03/2018.03.18 - unsorted/TaskB.java
Normal file
52
archive/2018.03/2018.03.18 - unsorted/TaskB.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.GCJSolution;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskB extends GCJSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
|
||||
int k = in.nextInt();
|
||||
|
||||
double[] a = in.nextDoubleArray(n);
|
||||
|
||||
double dipVal = 0;
|
||||
|
||||
// int removed = 0;
|
||||
//
|
||||
// List<Double> vals = new ArrayList<>();
|
||||
//
|
||||
// for (int i = 0; i < ; i++) {
|
||||
//
|
||||
// }
|
||||
|
||||
for (int i = 0; i < k + 1; i++) {
|
||||
double sum = 0;
|
||||
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (a[j] < dipVal) {
|
||||
sum += dipVal / n;
|
||||
} else {
|
||||
sum += a[j] / n;
|
||||
}
|
||||
}
|
||||
|
||||
dipVal = sum;
|
||||
}
|
||||
|
||||
out.println(dipVal);
|
||||
}
|
||||
}
|
449
archive/2018.03/2018.03.18 - unsorted/TaskB.task
Normal file
449
archive/2018.03/2018.03.18 - unsorted/TaskB.task
Normal file
File diff suppressed because one or more lines are too long
176
archive/2018.03/2018.03.18 - unsorted/TaskC.java
Normal file
176
archive/2018.03/2018.03.18 - unsorted/TaskC.java
Normal file
@@ -0,0 +1,176 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.GCJSolution;
|
||||
|
||||
|
||||
public class TaskC extends GCJSolution {
|
||||
|
||||
private int[] s;
|
||||
private int n;
|
||||
private Set<Integer> lengths;
|
||||
private HashMap<List<Integer>, Integer> masks;
|
||||
private String[] wordsS;
|
||||
private int wordCount;
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
long mod = 1000000007L;
|
||||
long base = 31;
|
||||
long[] bases = new long[30];
|
||||
|
||||
{
|
||||
bases[0] = 1;
|
||||
for (int i = 1; i < 30; i++) {
|
||||
bases[i] = bases[i - 1] * base % mod;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<Integer> maskl(int[] mask) {
|
||||
ArrayList<Integer> res = new ArrayList<>();
|
||||
for (int i : mask) {
|
||||
res.add(i);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
wordCount = in.nextInt();
|
||||
|
||||
wordsS = in.nextStringArray(wordCount);
|
||||
|
||||
// Map<Integer, List<Long>> lenToHashes = new HashMap<>();
|
||||
masks = new HashMap<>();
|
||||
|
||||
lengths = new HashSet<>();
|
||||
|
||||
for (String s : wordsS) {
|
||||
int l = s.length();
|
||||
lengths.add(l);
|
||||
// lenToHashes.putIfAbsent(l, new ArrayList<>());
|
||||
|
||||
int[] mask = new int[30];
|
||||
for (int i = 0; i < l; i++) {
|
||||
int c = s.charAt(i) - 97;
|
||||
mask[c]++;
|
||||
}
|
||||
mask[26] = s.charAt(0) - 97;
|
||||
mask[27] = s.charAt(l - 1) - 97;
|
||||
mask[28] = l;
|
||||
|
||||
ArrayList<Integer> maskl = maskl(mask);
|
||||
|
||||
masks.putIfAbsent(maskl, 0);
|
||||
masks.put(maskl, masks.get(maskl) + 1);
|
||||
}
|
||||
|
||||
long s1 = in.nextString().charAt(0);
|
||||
long s2 = in.nextString().charAt(0);
|
||||
|
||||
n = in.nextInt();
|
||||
s = new int[n];
|
||||
|
||||
{
|
||||
|
||||
long a = in.nextInt();
|
||||
long b = in.nextInt();
|
||||
long c = in.nextInt();
|
||||
long d = in.nextInt();
|
||||
|
||||
s[0] = (int) s1;
|
||||
s[1] = (int) s2;
|
||||
|
||||
for (int i = 2; i < n; i++) {
|
||||
s[i] = (int) ((a * s[i - 1] + b * s[i - 2] + c) % d);
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (i < 2) {
|
||||
s[i] -= 97;
|
||||
}
|
||||
s[i] %= 26;
|
||||
}
|
||||
}
|
||||
|
||||
int sol1 = sol1();
|
||||
|
||||
// int sol2 = sol2();
|
||||
int sol2 = sol1;
|
||||
|
||||
// out.println(sol1);
|
||||
|
||||
if (sol1 != sol2) {
|
||||
out.println("!!!!!!!!!!");
|
||||
out.println(sol1);
|
||||
out.println(sol2);
|
||||
} else {
|
||||
out.println(sol1);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
int sol1() {
|
||||
HashMap<List<Integer>, Integer> masks = new HashMap<>(this.masks);
|
||||
|
||||
int t = 0;
|
||||
|
||||
for (int l : lengths) {
|
||||
ArrayList<Integer> a = new ArrayList<>();
|
||||
for (int i = 0; i < 30; i++) {
|
||||
a.add(0);
|
||||
}
|
||||
|
||||
for (int i = 0; i < l; i++) {
|
||||
a.set(s[i], a.get(s[i]) + 1);
|
||||
}
|
||||
a.set(28, l);
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
a.set(26, s[i]);
|
||||
a.set(27, s[i + l - 1]);
|
||||
|
||||
if (masks.containsKey(a)) {
|
||||
t += masks.get(a);
|
||||
masks.remove(a);
|
||||
}
|
||||
|
||||
if (i + l >= n) {
|
||||
break;
|
||||
}
|
||||
|
||||
a.set(s[i], a.get(s[i]) - 1);
|
||||
a.set(s[i + l], a.get(s[i + l]) + 1);
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
|
||||
int sol2() {
|
||||
char[] s2 = new char[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
s2[i] = (char) (s[i] + 97);
|
||||
}
|
||||
|
||||
String s = new String(s2);
|
||||
|
||||
int t = 0;
|
||||
|
||||
for (String i : wordsS) {
|
||||
if (s.contains(i)) {
|
||||
t++;
|
||||
}
|
||||
}
|
||||
|
||||
return t;
|
||||
}
|
||||
}
|
427
archive/2018.03/2018.03.18 - unsorted/TaskC.task
Normal file
427
archive/2018.03/2018.03.18 - unsorted/TaskC.task
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user