git reimport
This commit is contained in:
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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
|
@@ -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);
|
||||
|
||||
}
|
||||
}
|
@@ -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 + " ");
|
||||
}
|
||||
}
|
||||
}
|
@@ -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();
|
||||
}
|
||||
}
|
106
archive/2018.03/2018.03.10 - VK Cup 2018 - Round 1/TaskD.java
Normal file
106
archive/2018.03/2018.03.10 - VK Cup 2018 - Round 1/TaskD.java
Normal 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');
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -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) {
|
||||
|
||||
}
|
||||
}
|
@@ -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) {
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user