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,39 @@
16 A - Primal Sport
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
3
0
3 14
2 6
1
1
3 20
3 15
1
2
5 8192
5 8191
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskA
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.10
21 VK Cup 2018 - Round 1
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,61 @@
18 B - Producing Snow
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
6
0
16 3
10 10 5
5 7 2
7 5 12 4
1
1
30 5
30 25 20 15 10
9 10 12 4 13
14 9 20 35 11 25
1
2
13 3
0 0 0
1 1 1
5 0 0 0
1
3
13 3
1 1 1
0 0 0
5 0 0 0
1
4
5 1
5
5
1 5
1
5
15 3
2 2 2
0 0 100
5 0 0 6
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskB
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.10
21 VK Cup 2018 - Round 1
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,45 @@
20 C - Perfect Security
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
3
0
16 3
8 4 13
17 2 7
8 10 3 28
1
1
30 5
12 7 87 22 11
18 39 9 12 16
13 0 14 69 6 44
1
2
203 10
331415699 278745619 998190004 423175621 42983144 166555524 843586353 802130100 337889448 685310951
226011312 266003835 342809544 504667531 529814910 684873393 817026985 844010788 993949858 1031395667
94 128965467 243912600 4281110 112029883 223689619 76924724 429589 119397893 613490433 362863284
1
11 src/chelper
8 -Xmx512M
4 Main
13 chelper.TaskC
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.10
21 VK Cup 2018 - Round 1
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,49 @@
19 D - Picking Strings
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
3
0
57 AABCCBAAB
ABCB
5
1 3 1 2
2 2 2 4
7 9 1 1
3 4 2 3
4 5 1 3
6 10011
1
1
24 AAA
AA
2
1 1 1 2
1 1 2 2
2 01
1
2
16 AA
ABC
1
1 2 1 3
1 1
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskD
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.10
21 VK Cup 2018 - Round 1
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,42 @@
25 E - Perpetual Subtraction
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
3
0
10 2 1
0 0 1
30 332748118 332748118 332748118
1
1
10 2 2
0 0 1
30 942786334 610038216 443664157
1
2
70 9 350
3 31 314 3141 31415 314159 3141592 31415926 314159265 649178508
97 822986014 12998613 84959018 728107923 939229297 935516344 27254497 413831286 583600448 442738326
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskE
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.10
21 VK Cup 2018 - Round 1
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,65 @@
18 F - Public Service
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
3
0
26 4
1 2
2 3
3 4
5 6
6 7
7 8
12 Yes
6 8 5 7
1
1
26 4
1 2
2 3
3 4
5 6
5 7
5 8
3 No
1
2
59 7
1 2
1 3
1 4
1 5
5 6
6 7
8 9
9 10
10 11
11 12
12 13
13 14
23 Yes
9 14 11 12 13 10 8
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskF
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.10
21 VK Cup 2018 - Round 1
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,74 @@
package chelper;
import java.util.ArrayList;
import java.util.List;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskA extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
List<Integer> primes(int n) {
boolean[] a = new boolean[n];
List<Integer> res = new ArrayList<>();
for (int i = 2; i < n; i++) {
if (a[i]) {
continue;
}
res.add(i);
for (int j = i; j < n; j += i) {
a[j] = true;
}
}
return res;
}
@Override
public void solve(int testNumber) {
int N = 1100000;
List<Integer> primes = primes(N);
int x2 = in.nextInt();
int r = x2 + 1;
int l = x2;
for (Integer prime : primes) {
if (x2 % prime == 0) {
l = x2 - prime + 1;
}
}
int minX0 = x2;
for (Integer prime : primes) {
int minX1 = (l + prime - 1) / prime * prime;
if (minX1 >= r) {
continue;
}
int next = minX1 - prime + 1;
if (minX1 == prime) {
next = prime;
}
minX0 = Math.min(minX0, next);
}
out.println(minX0);
}
}

View File

@@ -0,0 +1,89 @@
package chelper;
import java.util.Iterator;
import java.util.Objects;
import java.util.TreeSet;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskB extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
class MultiLong implements Comparable<MultiLong> {
long i;
long x;
public MultiLong(long i, long x) {
this.i = i;
this.x = x;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
MultiLong multiLong = (MultiLong) o;
return i == multiLong.i &&
x == multiLong.x;
}
@Override
public int hashCode() {
return Objects.hash(i, x);
}
@Override
public int compareTo(MultiLong o) {
int t = Long.compare(x, o.x);
if (t != 0) {
return t;
}
return Long.compare(i, o.i);
}
}
@Override
public void solve(int testNumber) {
int n = in.nextInt();
TreeSet<MultiLong> set = new TreeSet<>();
long[] v = in.nextLongArray(n);
long[] t = in.nextLongArray(n);
long corr = 0;
for (int i = 0; i < n; i++) {
long res = 0;
set.add(new MultiLong(i, v[i] + corr));
Iterator<MultiLong> iterator = set.iterator();
while (iterator.hasNext()) {
long x = iterator.next().x - corr;
if (x <= t[i]) {
res += x;
iterator.remove();
} else {
break;
}
}
res += set.size() * t[i];
corr += t[i];
out.print(res + " ");
}
}
}

View File

@@ -0,0 +1,86 @@
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);
}
int m = 31;
class Node {
Node child0;
Node child1;
int count = 0;
void add(boolean[] x, int i) {
count++;
if (i == m) {
return;
}
if (x[i]) {
if (child1 == null) {
child1 = new Node();
}
child1.add(x, i + 1);
} else {
if (child0 == null) {
child0 = new Node();
}
child0.add(x, i + 1);
}
}
int remove(boolean[] desired, int i) {
count--;
if (i == m) {
return 0;
}
Node child = desired[i] ? child1 : child0;
boolean node = (child != null && child.count > 0) == desired[i];
int r = node ? child1.remove(desired, i + 1) : child0.remove(desired, i + 1);
int add = (node ? 1 : 0) * (1 << (m - i - 1));
return r + add;
}
}
boolean[] explode(int x) {
boolean[] res = new boolean[m];
for (int i = 0; i < m; i++) {
res[m - i - 1] = x % 2 == 1;
x /= 2;
}
return res;
}
@Override
public void solve(int testNumber) {
int n = in.nextInt();
Node root = new Node();
int[] want = in.nextIntArray(n);
for (int i = 0; i < n; i++) {
root.add(explode(in.nextInt()), 0);
}
for (int i = 0; i < n; i++) {
int x = root.remove(explode(want[i]), 0) ^ want[i];
out.print(x + " ");
}
out.println();
}
}

View File

@@ -0,0 +1,106 @@
package chelper;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskD extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
@Override
public void solve(int testNumber) {
char[] a = in.nextString().toCharArray();
char[] b = in.nextString().toCharArray();
int n = a.length;
int m = b.length;
int q = in.nextInt();
int[] aCumSum1 = new int[n];
int[] bCumSum1 = new int[m];
for (int i = 0; i < n; i++) {
if (i > 0) {
aCumSum1[i] += aCumSum1[i - 1];
}
if (a[i] == 'B' || a[i] == 'C') {
aCumSum1[i]++;
}
}
for (int i = 0; i < m; i++) {
if (i > 0) {
bCumSum1[i] += bCumSum1[i - 1];
}
if (b[i] == 'B' || b[i] == 'C') {
bCumSum1[i]++;
}
}
int[] aCumSum2 = new int[n];
int[] bCumSum2 = new int[m];
for (int i = 0; i < n; i++) {
if (i > 0) {
aCumSum2[i] += aCumSum2[i - 1];
}
if (a[i] == 'A') {
aCumSum2[i]++;
} else {
aCumSum2[i] = 0;
}
}
for (int i = 0; i < m; i++) {
if (i > 0) {
bCumSum2[i] += bCumSum2[i - 1];
}
if (b[i] == 'A') {
bCumSum2[i]++;
} else {
bCumSum2[i] = 0;
}
}
for (int i = 0; i < q; i++) {
int al = in.nextInt() - 1;
int ar = in.nextInt() - 1;
int bl = in.nextInt() - 1;
int br = in.nextInt() - 1;
int x_bc = aCumSum1[ar];
if (al > 0) {
x_bc -= aCumSum1[al - 1];
}
int x_a = aCumSum2[ar];
if (al > 0 && aCumSum1[ar] == aCumSum1[al - 1]) {
x_a -= aCumSum2[al - 1];
}
int y_bc = bCumSum1[br];
if (bl > 0) {
y_bc -= bCumSum1[bl - 1];
}
int y_a = bCumSum2[br];
if (bl > 0 && bCumSum1[br] == bCumSum1[bl - 1]) {
y_a -= bCumSum2[bl - 1];
}
boolean ok;
ok = (x_a >= y_a) && ((x_a - y_a) % 3 == 0);
ok &= (x_bc <= y_bc) && ((y_bc - x_bc) % 2 == 0);
out.print(ok ? '1' : '0');
}
}
}

View File

@@ -0,0 +1,18 @@
package chelper;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskE extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
@Override
public void solve(int testNumber) {
}
}

View File

@@ -0,0 +1,18 @@
package chelper;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskF extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
@Override
public void solve(int testNumber) {
}
}

View 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");
}
}
}

View 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

View 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));
}
}

View 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

View 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);
}
}

File diff suppressed because one or more lines are too long

View 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;
}
}

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,54 @@
19 A - Mystical Mosaic
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
3
0
49 5 8
.#.#..#.
.....#..
.#.#..#.
#.#....#
.....#..
4 Yes
1
1
34 5 5
..#..
..#..
#####
..#..
..#..
3 No
1
2
54 5 9
........#
#........
..##.#...
.......#.
....#.#.#
3 No
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskA
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.24
21 VK Cup 2018 - Round 2
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,42 @@
21 B - Three-level Laser
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
3
0
12 4 4
1 3 5 7
4 0.5
1
1
35 10 8
10 13 15 16 17 19 20 22 24 25
6 0.875
1
2
11 3 1
2 5 10
3 -1
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskB
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.24
21 VK Cup 2018 - Round 2
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,100 @@
19 C - Riverside Curio
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
14
0
14 6
0 1 0 3 0 2
2 6
1
1
12 5
0 1 2 1 2
2 1
1
2
12 5
0 1 1 2 2
2 0
1
3
13 6
0 1 2 3 4 0
1 4
1
4
11 5
0 0 0 0 4
1 6
1
5
11 5
0 0 0 0 0
1 0
1
6
11 5
0 1 0 0 0
1 3
1
7
17 8
0 1 0 0 0 0 0 5
2 11
1
8
3 1
0
1 0
1
9
7 3
0 1 2
1 0
1
10
46 11
0 0 0 0 4 0 0 0 0 0 6
0 1 2 3 4 4 4 4 4 5 6
2 27
1
11
37 9
0 1 2 3 4 3 2 1 0
0 1 2 3 4 4 4 4 4
2 10
1
12
54 13
0 0 1 0 0 1 0 0 1 6 0 0 0
0 0 1 1 1 2 3 4 5 6 6 6 6
2 32
1
13
22 10
0 1 2 3 1 1 1 1 1 1
2 12
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskC
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.24
21 VK Cup 2018 - Round 2
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,80 @@
15 D - Contact ATC
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
7
0
29 5 1
-3 2
-3 3
-1 2
1 -3
3 -5
2 3
1
1
34 6 1
-3 2
-2 2
-1 2
1 -2
2 -2
3 -2
2 9
1
2
23 4 0
-1 1
-2 2
3 -3
4 -4
1 4
0
3
23 4 0
-1 1
-2 2
3 -3
4 -5
1 2
0
4
25 4 100
-1 1
-2 2
3 -3
4 -5
1 4
0
5
13 2 0
-1 1
-2 2
1 1
1
6
15 2 2
6 -4
24 -10
1 1
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskD
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.24
21 VK Cup 2018 - Round 2
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,37 @@
12 E - Wardrobe
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
2
0
26 5 3 6
3 2 5 1 2
1 1 0 1 0
2 2
1
1
14 2 2 5
3 6
1 1
2 1
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskE
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.24
21 VK Cup 2018 - Round 2
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,71 @@
29 F - Minimal Subset Difference
6 SINGLE
8 STANDARD
-1
8 STANDARD
-1
2
0
83 10
1 100 0
1 100 1
1 100 2
1 100 3
1 100 4
1 100 5
1 100 6
1 100 7
1 100 8
1 100 9
30 9
28
44
58
70
80
88
94
98
100
1
1
93 10
1 1000 0
1 1000 1
1 1000 2
1 1000 3
1 1000 4
1 1000 5
1 1000 6
1 1000 7
1 1000 8
1 1000 9
41 135
380
573
721
830
906
955
983
996
1000
1
11 src/chelper
8 -Xmx256M
4 Main
13 chelper.TaskF
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.24
21 VK Cup 2018 - Round 2
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,61 @@
package chelper;
import java.util.HashSet;
import java.util.Set;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskA 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 m = in.nextInt();
boolean[][] a = new boolean[n][m];
for (int i = 0; i < n; i++) {
String s = in.nextString();
for(int j = 0; j < m; j++) {
a[i][j] = s.charAt(j) == '#';
}
}
boolean ok = true;
for (int i = 0; i < n; i++) {
Set<Integer> atBaseLine = new HashSet<>();
for (int j = 0; j < m; j++) {
if (a[i][j]) {
atBaseLine.add(j);
}
}
for (int ii = i + 1; ii < n; ii++) {
Set<Integer> atNextLine = new HashSet<>();
for (int j = 0; j < m; j++) {
if (a[ii][j]) {
atNextLine.add(j);
}
}
Set<Integer> intersection = new HashSet<>(atBaseLine);
intersection.retainAll(atNextLine);
if (!intersection.isEmpty() && !atBaseLine.equals(atNextLine)) {
ok = false;
}
}
}
out.println(ok ? "Yes" : "No");
}}

View File

@@ -0,0 +1,21 @@
package chelper;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskB 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 u = in.nextInt();
}
}

View File

@@ -0,0 +1,112 @@
package chelper;
import java.util.Objects;
import java.util.SortedMap;
import java.util.TreeMap;
import java.util.TreeSet;
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);
}
class Pos implements Comparable<Pos> {
long height;
int pos;
public Pos(long height, int pos) {
this.height = height;
this.pos = pos;
}
@Override
public int compareTo(Pos o) {
int t = Long.compare(height, o.height);
if (t != 0) {
return t;
}
return -Integer.compare(pos, o.pos);
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Pos pos1 = (Pos) o;
return height == pos1.height &&
pos == pos1.pos;
}
@Override
public int hashCode() {
return Objects.hash(height, pos);
}
}
@Override
public void solve(int testNumber) {
int n = in.nextInt();
long[] above = in.nextLongArray(n);
long[] total = new long[n];
TreeSet<Pos> poses = new TreeSet<>();
for (int i = 0; i < n; i++) {
poses.add(new Pos(above[i], i));
}
// poses.add(new Pos(-1, -1));
Pos highest = poses.pollLast();
total[highest.pos] = highest.height;
// while (!poses.isEmpty()) {
// Pos next = poses.pollLast();
// if (next.pos > highest.pos) {
// continue;
// }
//
// long h = highest.height;
//
// for (int i = highest.pos; i >= Math.max(next.pos, 0); i--) {
// total[i] = h;
// if (h > next.height) {
// h--;
// }
// }
//
// highest = next;
// }
long h = highest.height;
for (int pos = highest.pos; pos < n; pos++) {
poses.remove(new Pos(above[pos], pos));
total[pos] = h;
}
for (int pos = highest.pos - 1; pos >= 0; pos--) {
if (h > poses.last().height) {
h--;
}
total[pos] = h;
poses.remove(new Pos(above[pos], pos));
}
h = 0;
long sum = 0;
for (int i = 0; i < n; i++) {
// h = Math.max(h, total[i]);
sum += total[i] - above[i];
}
out.println(sum);
}
}

View File

@@ -0,0 +1,185 @@
package chelper;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.TreeMap;
import java.util.TreeSet;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskD extends SimpleSavingChelperSolution {
private Comparator<Interval> sortLeft = new Comparator<Interval>() {
@Override
public int compare(Interval o1, Interval o2) {
int t = o1.l.compareTo(o2.l);
if (t != 0) {
return t;
}
return Integer.compare(o1.i, o2.i);
}
};
private Comparator<Interval> sortRight = new Comparator<Interval>() {
@Override
public int compare(Interval o1, Interval o2) {
int t = o1.r.compareTo(o2.r);
if (t != 0) {
return t;
}
return Integer.compare(o1.i, o2.i);
}
};
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
class Ratio implements Comparable<Ratio> {
long num, denom;
public Ratio(long num, long denom) {
this.num = num;
this.denom = denom;
}
@Override
public int compareTo(Ratio o) {
long a = num * o.denom;
long b = o.num * denom;
return Long.compare(a, b);
}
}
class Interval {
Ratio l, r;
int i;
int order = -1;
public Interval(Ratio l, Ratio r, int i) {
this.l = l;
this.r = r;
this.i = i;
}
}
long countOneSide(List<Interval> intervals) {
}
@Override
public void solve(int testNumber) {
int n = in.nextInt();
int maxW = in.nextInt();
List<Interval> left = new ArrayList<>();
List<Interval> right = new ArrayList<>();
long res = 0;
for (int i = 0; i < n; i++) {
int x = in.nextInt();
int v = in.nextInt();
// double minTime = Math.abs(x) / (Math.abs(v) + maxW);
// double maxTime = Math.abs(x) / (Math.abs(v) - maxW);
Ratio minTime = new Ratio(Math.abs(x), Math.abs(v) + maxW);
Ratio maxTime = new Ratio(Math.abs(x), Math.abs(v) - maxW);
if (x < 0) {
left.add(new Interval(minTime, maxTime, i));
} else {
right.add(new Interval(minTime, maxTime, i));
}
}
Comparator<Interval> check = new Comparator<Interval>() {
@Override
public int compare(Interval o1, Interval o2) {
int t = o1.l.compareTo(o2.l);
if (t != 0) {
return t;
}
t = o1.r.compareTo(o2.r);
return t;
}
;
};
TreeMap<Interval, Integer> s = new TreeMap<>(check);
for (Interval interval : left) {
s.putIfAbsent(interval, 0);
s.put(interval, s.get(interval) + 1);
}
for (Integer integer : s.values()) {
res += (integer - 1L) * (integer - 0L) / 2;
}
s = new TreeMap<>(check);
for (Interval interval : right) {
s.putIfAbsent(interval, 0);
s.put(interval, s.get(interval) + 1);
}
for (Integer integer : s.values()) {
res += (integer - 1L) * (integer - 0L) / 2;
}
TreeSet<Interval> rightSortLeft = new TreeSet<>(sortLeft);
for (Interval interval : right) {
rightSortLeft.add(new Interval(interval.l, interval.r, interval.i));
}
int howManyLeft = right.size();
for (Interval interval : rightSortLeft) {
interval.order = howManyLeft;
howManyLeft--;
}
TreeSet<Interval> rightSortRight = new TreeSet<>(sortRight);
for (Interval interval : right) {
rightSortRight.add(new Interval(interval.l, interval.r, interval.i));
}
howManyLeft = 0;
for (Interval interval : rightSortRight) {
howManyLeft++;
interval.order = howManyLeft;
}
for (Interval interval : left) {
Interval higher = rightSortLeft.higher(new Interval(interval.r, interval.r, n));
int toRight = 0;
if (higher != null) {
toRight = higher.order;
}
Interval lower = rightSortRight.lower(new Interval(interval.l, interval.l, -1));
int toLeft = 0;
if (lower != null) {
toLeft = lower.order;
}
res += right.size() - toLeft - toRight;
}
out.println(res);
}
}

View File

@@ -0,0 +1,18 @@
package chelper;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskE extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
@Override
public void solve(int testNumber) {
}
}

View File

@@ -0,0 +1,18 @@
package chelper;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class TaskF extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
@Override
public void solve(int testNumber) {
}
}

View File

@@ -0,0 +1,62 @@
package chelper;
import java.util.HashSet;
import java.util.Set;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class A 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 m = in.nextInt();
boolean[][] a = new boolean[n][m];
for (int i = 0; i < n; i++) {
String s = in.nextString();
for(int j = 0; j < m; j++) {
a[i][j] = s.charAt(j) == '#';
}
}
boolean ok = true;
for (int i = 0; i < n; i++) {
Set<Integer> atBaseLine = new HashSet<>();
for (int j = 0; j < m; j++) {
if (a[i][j]) {
atBaseLine.add(j);
}
}
for (int ii = i + 1; ii < n; ii++) {
Set<Integer> atNextLine = new HashSet<>();
for (int j = 0; j < m; j++) {
if (a[ii][j]) {
atNextLine.add(j);
}
}
Set<Integer> intersection = new HashSet<>(atBaseLine);
intersection.retainAll(atNextLine);
if (!intersection.isEmpty() && !atBaseLine.equals(atNextLine)) {
ok = false;
}
}
}
out.println(ok ? "Yes" : "No");
}
}

View File

@@ -0,0 +1,21 @@
1 A
6 SINGLE
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
0
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
9 chelper.A
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.03.24
0
1
14 io.InputReader
15 io.OutputWriter
0
0