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,69 @@
package chelper;
import java.util.ArrayList;
import java.util.List;
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);
}
long get(List<Integer> a) {
long res = 0;
long t = 1;
for (int i : a) {
res += i * t;
t *= 2;
}
return res;
}
@Override
public void solve(int testNumber) {
long d = in.nextLong();
String s = in.nextString();
List<Integer> a = new ArrayList<>();
int t = 0;
for (char c : s.toCharArray()) {
if (c == 'C') {
a.add(t);
t = 0;
}
if (c == 'S') {
t++;
}
}
if (t > 0) {
a.add(t);
}
int c = 0;
while (get(a) > d) {
c++;
if (a.size() == 1) {
out.println("IMPOSSIBLE");
return;
}
a.set(a.size() - 1, a.get(a.size() - 1) - 1);
a.set(a.size() - 2, a.get(a.size() - 2) + 1);
if (a.get(a.size() - 1) == 0) {
a.remove(a.size() - 1);
}
}
out.println(c);
}
}

View File

@@ -0,0 +1,36 @@
5 TaskA
12 MULTI_NUMBER
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
1
0
38 6
1 CS
2 CS
1 SS
6 SCCSSC
2 CC
3 CSCSS
74 Case #1: 1
Case #2: 0
Case #3: IMPOSSIBLE
Case #4: 2
Case #5: 0
Case #6: 5
1
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
13 chelper.TaskA
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.04.07
0
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,50 @@
package chelper;
import java.util.ArrayList;
import java.util.Collections;
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[] a = in.nextIntArray(n);
List<Integer> even = new ArrayList<>();
List<Integer> odd = new ArrayList<>();
for (int i = 0; i < n; i++) {
if (i % 2 == 0) {
even.add(a[i]);
} else {
odd.add(a[i]);
}
}
Collections.sort(even);
Collections.sort(odd);
for (int i = 0; i < n - 1; i++) {
int x = i % 2 == 0 ? even.get(i / 2) : odd.get(i / 2);
int y = (i + 1) % 2 == 0 ? even.get((i + 1) / 2) : odd.get((i + 1) / 2);
if (x > y) {
out.println(i);
return;
}
}
out.println("OK");
}
}

View File

@@ -0,0 +1,30 @@
5 TaskB
12 MULTI_NUMBER
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
1
0
21 2
5
5 6 8 4 3
3
8 9 7
22 Case #1: OK
Case #2: 1
1
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
13 chelper.TaskB
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.04.07
0
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,98 @@
package chelper;
import java.util.Objects;
import java.util.TreeSet;
import io.InputReader;
import io.OutputWriter;
public class TaskC {
class Point implements Comparable<Point> {
public final int x;
public final int y;
public Point(int x, int y) {
this.x = x;
this.y = y;
}
@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Point point = (Point) o;
return x == point.x &&
y == point.y;
}
@Override
public int hashCode() {
return Objects.hash(x, y);
}
@Override
public int compareTo(Point o) {
int t = Integer.compare(x, o.x);
if (t != 0) {
return t;
}
return Integer.compare(y, o.y);
}
}
public void solve(int testNumber, InputReader in, OutputWriter out) {
int area = in.nextInt();
int w, h;
int offsetX = 100;
int offsetY = 100;
if (area == 20) {
w = 5;
h = 4;
} else {
w = 20;
h = 10;
}
TreeSet<Point> missing = new TreeSet<>();
for (int i = 0; i < w; i++) {
for (int j = 0; j < h; j++) {
missing.add(new Point(i, j));
}
}
while (!missing.isEmpty()) {
Point p = missing.first();
int x = p.x + 1;
int y = p.y;
x = Math.max(1, Math.min(w - 2, x)) + offsetX;
y = Math.max(1, Math.min(h - 2, y)) + offsetY;
out.println(x + " " + y);
out.flush();
int xi = in.nextInt();
int yi = in.nextInt();
if (xi == -1 && yi == -1) {
throw new RuntimeException("something's bad");
}
if (xi == 0 && yi == 0) {
break;
}
Point p2 = new Point(xi - offsetX, yi - offsetY);
missing.remove(p2);
}
}
}

View File

@@ -0,0 +1,26 @@
5 TaskC
12 MULTI_NUMBER
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
1
0
4 1
20
-1
1
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
13 chelper.TaskC
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2018.04.07
0
1
14 io.InputReader
15 io.OutputWriter
0
0