git reimport
This commit is contained in:
11
archive/2016.03/2016.03.31 - unsorted/Task93213.java
Normal file
11
archive/2016.03/2016.03.31 - unsorted/Task93213.java
Normal file
@@ -0,0 +1,11 @@
|
||||
package chelper;
|
||||
|
||||
import misc.SimpleBasicSolution;
|
||||
|
||||
public class Task93213 extends SimpleBasicSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
|
||||
}
|
||||
}
|
21
archive/2016.03/2016.03.31 - unsorted/Task93213.task
Normal file
21
archive/2016.03/2016.03.31 - unsorted/Task93213.task
Normal file
@@ -0,0 +1,21 @@
|
||||
9 Task93213
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
0
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
17 chelper.Task93213
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.03.31
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
105
archive/2016.07/2016.07.23 - unsorted/Timus1651.java
Normal file
105
archive/2016.07/2016.07.23 - unsorted/Timus1651.java
Normal file
@@ -0,0 +1,105 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class Timus1651 {
|
||||
public void solve2(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int[] a = in.nextIntArray(n);
|
||||
|
||||
int[] best = new int[100000];
|
||||
int[] from = new int[100000];
|
||||
|
||||
Arrays.fill(best, Integer.MAX_VALUE);
|
||||
best[a[0]] = 0;
|
||||
from[a[0]] = 0;
|
||||
|
||||
for (int i = 1; i < n; i++) {
|
||||
int t = a[i];
|
||||
int p = a[i - 1];
|
||||
if (best[t] > best[p] + 1) {
|
||||
best[t] = best[p] + 1;
|
||||
from[t] = i;
|
||||
}
|
||||
}
|
||||
|
||||
LinkedList<Integer> result = new LinkedList<>();
|
||||
|
||||
for (int c = n - 1; c >= 0;) {
|
||||
int t = a[c];
|
||||
result.addFirst(t);
|
||||
c = from[t] - 1;
|
||||
}
|
||||
|
||||
for (int i : result) {
|
||||
out.print(i + " ");
|
||||
}
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int[] a = in.nextIntArray(n);
|
||||
|
||||
int M = 100100;
|
||||
|
||||
List<List<Integer>> edges = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < M; i++) {
|
||||
edges.add(new ArrayList<>());
|
||||
}
|
||||
|
||||
for (int i = 1; i < n; i++) {
|
||||
int t = a[i];
|
||||
int p = a[i - 1];
|
||||
edges.get(p).add(t);
|
||||
}
|
||||
|
||||
int start = a[0];
|
||||
int finish = a[n - 1];
|
||||
|
||||
int[] dist = new int[M];
|
||||
Arrays.fill(dist, Integer.MAX_VALUE);
|
||||
dist[start] = 0;
|
||||
|
||||
int[] from = new int[M];
|
||||
from[start] = -1;
|
||||
|
||||
List<Integer> vertices = new ArrayList<>();
|
||||
vertices.add(a[0]);
|
||||
while (!vertices.isEmpty()) {
|
||||
List<Integer> newVertices = new ArrayList<>();
|
||||
|
||||
for (int i : vertices) {
|
||||
for (int j : edges.get(i)) {
|
||||
if (dist[j] == Integer.MAX_VALUE) {
|
||||
dist[j] = dist[i] + 1;
|
||||
from[j] = i;
|
||||
newVertices.add(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
vertices = newVertices;
|
||||
}
|
||||
|
||||
LinkedList<Integer> result = new LinkedList<>();
|
||||
|
||||
for (int t = finish; t >= 0;) {
|
||||
result.addFirst(t);
|
||||
t = from[t];
|
||||
}
|
||||
|
||||
for (int i : result) {
|
||||
out.print(i + " ");
|
||||
}
|
||||
}
|
||||
}
|
42
archive/2016.07/2016.07.23 - unsorted/Timus1651.task
Normal file
42
archive/2016.07/2016.07.23 - unsorted/Timus1651.task
Normal file
@@ -0,0 +1,42 @@
|
||||
9 Timus1651
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
4
|
||||
0
|
||||
19 9
|
||||
1 2 7 3 2
|
||||
8 4 8 5
|
||||
7 1 2 8 5
|
||||
1
|
||||
1
|
||||
19 9
|
||||
1 2 3 4 5 2 6 7 3
|
||||
5 1 2 3
|
||||
1
|
||||
2
|
||||
7 3
|
||||
1 2 1
|
||||
1 1
|
||||
1
|
||||
3
|
||||
5 2
|
||||
1 1
|
||||
1 1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
17 chelper.Timus1651
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.07.23
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
67
archive/2016.08/2016.08.01 - unsorted/Sazanka0G.java
Normal file
67
archive/2016.08/2016.08.01 - unsorted/Sazanka0G.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class Sazanka0G {
|
||||
int[] powers = new int[10];
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int k = 6;
|
||||
|
||||
for (int i = 0; i < 10; i++) {
|
||||
powers[i] = (int) Math.pow(i, k);
|
||||
}
|
||||
|
||||
int[] dp = new int[10000000];
|
||||
Arrays.fill(dp, -1);
|
||||
|
||||
long sum = 0;
|
||||
for (int i = 1; i <= 1000000; i++) {
|
||||
sum += f(i, dp);
|
||||
}
|
||||
out.println(sum);
|
||||
}
|
||||
|
||||
int nextHappy(int n) {
|
||||
int x = n;
|
||||
int ans = 0;
|
||||
while (x > 0) {
|
||||
int t = x % 10;
|
||||
x /= 10;
|
||||
ans += powers[t];
|
||||
}
|
||||
return ans;
|
||||
}
|
||||
|
||||
int f(int x, int[] dp) {
|
||||
if (dp[x] == -1) {
|
||||
int t = nextHappy(x);
|
||||
dp[x] = -2;
|
||||
dp[x] = Math.min(x, f(t, dp));
|
||||
}
|
||||
if (dp[x] == -2) { // found loop
|
||||
Set<Integer> loop = new HashSet<>();
|
||||
int t = x;
|
||||
while (true) {
|
||||
loop.add(t);
|
||||
t = nextHappy(t);
|
||||
if (t == x) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
int min = Integer.MAX_VALUE;
|
||||
for (int i : loop) {
|
||||
min = Math.min(min, i);
|
||||
}
|
||||
for (int i : loop) {
|
||||
dp[i] = min;
|
||||
}
|
||||
}
|
||||
return dp[x];
|
||||
}
|
||||
}
|
25
archive/2016.08/2016.08.01 - unsorted/Sazanka0G.task
Normal file
25
archive/2016.08/2016.08.01 - unsorted/Sazanka0G.task
Normal file
@@ -0,0 +1,25 @@
|
||||
9 Sazanka0G
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
0
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
17 chelper.Sazanka0G
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.01
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
152
archive/2016.08/2016.08.03 - unsorted/Sazanka2J.java
Normal file
152
archive/2016.08/2016.08.03 - unsorted/Sazanka2J.java
Normal file
@@ -0,0 +1,152 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
|
||||
public class Sazanka2J {
|
||||
|
||||
class Edge {
|
||||
|
||||
int a, b;
|
||||
|
||||
Edge(int a, int b) {
|
||||
this.a = a;
|
||||
this.b = b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof Edge)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Edge edge = (Edge) o;
|
||||
|
||||
if (a != edge.a) {
|
||||
return false;
|
||||
}
|
||||
return b == edge.b;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = a;
|
||||
result = 31 * result + b;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<Integer>[] leftToRightEdges;
|
||||
boolean[][] graphToLeft;
|
||||
boolean[][] graphToRight;
|
||||
boolean[] usedLeft;
|
||||
boolean[] usedRight;
|
||||
int m, n;
|
||||
|
||||
void dfs(int x, boolean left) {
|
||||
// System.out.println("dfs run " + x + " " + left);
|
||||
if (left) {
|
||||
usedLeft[x] = true;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (graphToRight[x][i] && !usedRight[i]) {
|
||||
dfs(i, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
usedRight[x] = true;
|
||||
for (int i = 0; i < m; i++) {
|
||||
if (graphToLeft[x][i] && !usedLeft[i]) {
|
||||
dfs(i, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
m = in.nextInt();
|
||||
n = in.nextInt();
|
||||
|
||||
leftToRightEdges = new ArrayList[m];
|
||||
for (int i = 0; i < m; i++) {
|
||||
leftToRightEdges[i] = new ArrayList<>();
|
||||
int k = in.nextInt();
|
||||
for (int j = 0; j < k; j++) {
|
||||
leftToRightEdges[i].add(in.nextInt() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
boolean[] nasucsh = new boolean[m];
|
||||
Set<Edge> parsoch = new HashSet<>();
|
||||
for (int i = 0; i < m; i++) {
|
||||
int x = in.nextInt();
|
||||
if (x > 0) {
|
||||
parsoch.add(new Edge(i, x - 1));
|
||||
nasucsh[i] = true;
|
||||
}
|
||||
}
|
||||
|
||||
graphToLeft = new boolean[n][m];
|
||||
graphToRight = new boolean[m][n];
|
||||
for (int i = 0; i < m; i++) {
|
||||
for (int j : leftToRightEdges[i]) {
|
||||
if (parsoch.contains(new Edge(i, j))) {
|
||||
graphToLeft[j][i] = true;
|
||||
// System.out.println("toleft " + j + " " + i);
|
||||
} else {
|
||||
graphToRight[i][j] = true;
|
||||
// System.out.println("toright " + i + " " + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
usedLeft = new boolean[m];
|
||||
usedRight = new boolean[n];
|
||||
for (int i = 0; i < m; i++) {
|
||||
if (!nasucsh[i]) {
|
||||
// out.println("dfs " + i);
|
||||
dfs(i, true);
|
||||
}
|
||||
}
|
||||
|
||||
ArrayList<Integer> answerLeft = new ArrayList<>();
|
||||
ArrayList<Integer> answerRight = new ArrayList<>();
|
||||
|
||||
Collections.sort(answerLeft);
|
||||
Collections.sort(answerRight);
|
||||
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
if (!usedLeft[i]) {
|
||||
answerLeft.add(i);
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (usedRight[i]) {
|
||||
answerRight.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
out.println(answerLeft.size() + answerRight.size());
|
||||
|
||||
out.print(answerLeft.size() + " ");
|
||||
for (int i : answerLeft) {
|
||||
out.print(i + 1 + " ");
|
||||
}
|
||||
out.println();
|
||||
out.print(answerRight.size() + " ");
|
||||
for (int i : answerRight) {
|
||||
out.print(i + 1 + " ");
|
||||
}
|
||||
}
|
||||
}
|
31
archive/2016.08/2016.08.03 - unsorted/Sazanka2J.task
Normal file
31
archive/2016.08/2016.08.03 - unsorted/Sazanka2J.task
Normal file
@@ -0,0 +1,31 @@
|
||||
9 Sazanka2J
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
23 3 2
|
||||
2 1 2
|
||||
1 2
|
||||
1 2
|
||||
1 2 0
|
||||
9 2
|
||||
1 1
|
||||
1 2
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
17 chelper.Sazanka2J
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.03
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
115
archive/2016.08/2016.08.04 - unsorted/GroupedWord.java
Normal file
115
archive/2016.08/2016.08.04 - unsorted/GroupedWord.java
Normal file
@@ -0,0 +1,115 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class GroupedWord {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
String[] a = in.nextStringArray(n);
|
||||
|
||||
out.println(restore(a));
|
||||
}
|
||||
|
||||
String restore(String[] a) {
|
||||
List<String> list = new ArrayList<>();
|
||||
Collections.addAll(list, a);
|
||||
|
||||
for (char c = 'a'; c <= 'z'; c++) {
|
||||
List<String> interesting = new ArrayList<>();
|
||||
for (int i = 0; i < list.size();) {
|
||||
if (list.get(i).contains("" + c)) {
|
||||
interesting.add(list.get(i));
|
||||
list.remove(i);
|
||||
} else {
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
if (interesting.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String result = combine(c, interesting);
|
||||
if (result == null) {
|
||||
return "IMPOSSIBLE";
|
||||
}
|
||||
list.add(result);
|
||||
}
|
||||
|
||||
if (list.size() > 1) {
|
||||
return "MANY";
|
||||
}
|
||||
return list.get(0);
|
||||
}
|
||||
|
||||
boolean isInvalid(String s) {
|
||||
for (int i = 0; i < s.length(); i++) {
|
||||
for (int j = i + 1; j < s.length(); j++) {
|
||||
if (s.charAt(i) == s.charAt(j) && s.charAt(i) != s.charAt(i + 1)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
String combine(char c, List<String> interesting) {
|
||||
List<String> only = new ArrayList<>();
|
||||
List<String> starts = new ArrayList<>();
|
||||
List<String> ends = new ArrayList<>();
|
||||
List<String> middle = new ArrayList<>();
|
||||
|
||||
for (String s : interesting) {
|
||||
if (isInvalid(s)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
boolean doesStart = s.charAt(0) == c;
|
||||
boolean doesEnd = s.charAt(s.length() - 1) == c;
|
||||
|
||||
if (doesStart) {
|
||||
if (doesEnd) {
|
||||
only.add(s);
|
||||
} else {
|
||||
starts.add(s);
|
||||
}
|
||||
} else {
|
||||
if (doesEnd) {
|
||||
ends.add(s);
|
||||
} else {
|
||||
middle.add(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (starts.size() > 1 || ends.size() > 1 || middle.size() > 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!middle.isEmpty()) {
|
||||
if (only.isEmpty() && starts.isEmpty() && ends.isEmpty()) {
|
||||
return middle.get(0);
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for (String s : ends) {
|
||||
sb.append(s);
|
||||
}
|
||||
for (String s : only) {
|
||||
sb.append(s);
|
||||
}
|
||||
for (String s : starts) {
|
||||
sb.append(s);
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
}
|
55
archive/2016.08/2016.08.04 - unsorted/GroupedWord.task
Normal file
55
archive/2016.08/2016.08.04 - unsorted/GroupedWord.task
Normal file
@@ -0,0 +1,55 @@
|
||||
11 GroupedWord
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
5
|
||||
0
|
||||
14 4
|
||||
abab
|
||||
bb
|
||||
bc
|
||||
k
|
||||
10 IMPOSSIBLE
|
||||
0
|
||||
1
|
||||
10 3
|
||||
aaa
|
||||
a
|
||||
aa
|
||||
6 aaaaaa
|
||||
1
|
||||
2
|
||||
8 2
|
||||
ab
|
||||
bba
|
||||
10 IMPOSSIBLE
|
||||
1
|
||||
3
|
||||
7 2
|
||||
te
|
||||
st
|
||||
4 stte
|
||||
1
|
||||
4
|
||||
8 3
|
||||
te
|
||||
s
|
||||
t
|
||||
4 MANY
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
19 chelper.GroupedWord
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.04
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
150
archive/2016.08/2016.08.04 - unsorted/Sazanka2N.java
Normal file
150
archive/2016.08/2016.08.04 - unsorted/Sazanka2N.java
Normal file
@@ -0,0 +1,150 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
|
||||
public class Sazanka2N {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
StringBuilder[] strings = new StringBuilder[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
strings[i] = new StringBuilder(in.nextString());
|
||||
}
|
||||
|
||||
List<StringBuilder> same = new ArrayList<>();
|
||||
List<StringBuilder> notSame = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (sameChars(strings[i])) {
|
||||
same.add(strings[i]);
|
||||
} else {
|
||||
notSame.add(strings[i]);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < notSame.size(); i++) {
|
||||
char need = notSame.get(i).charAt(notSame.get(i).length() - 1);
|
||||
for (int j = same.size() - 1; j >= 0; j--) {
|
||||
if (same.get(j).charAt(0) == need) {
|
||||
notSame.set(i, notSame.get(i).append(same.get(j)));
|
||||
same.remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < same.size(); i++) {
|
||||
char need = same.get(i).charAt(0);
|
||||
for (int j = notSame.size() - 1; j >= 0; j--) {
|
||||
if (notSame.get(j).charAt(0) == need) {
|
||||
same.set(i, same.get(i).append(notSame.get(j)));
|
||||
notSame.remove(j);
|
||||
}
|
||||
}
|
||||
}
|
||||
ArrayList<StringBuilder> all = new ArrayList<>();
|
||||
all.addAll(same);
|
||||
all.addAll(notSame);
|
||||
|
||||
for (int i = 0; i < all.size(); i++) {
|
||||
for (int j = 0; j < all.size(); j++) {
|
||||
char need = all.get(i).charAt(all.get(i).length() - 1);
|
||||
if (i == j) {
|
||||
continue;
|
||||
}
|
||||
if (all.get(j).charAt(0) == need) {
|
||||
all.set(i, all.get(i).append(all.get(j)));
|
||||
all.remove(j);
|
||||
j = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (all.size() > 1) {
|
||||
if (isOkWords(all)) {
|
||||
out.print("MANY");
|
||||
} else {
|
||||
out.print("IMPOSSIBLE");
|
||||
}
|
||||
} else if (isOkWord(all.get(0))) {
|
||||
out.print(all.get(0));
|
||||
} else {
|
||||
out.print("IMPOSSIBLE");
|
||||
}
|
||||
}
|
||||
|
||||
private boolean sameChars(StringBuilder string) {
|
||||
char need = string.charAt(0);
|
||||
for (int i = 1; i < string.length(); i++) {
|
||||
if (string.charAt(i) != need) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean isOkWords(ArrayList<StringBuilder> strings) {
|
||||
Set<Character> chars = new HashSet<>();
|
||||
for (int i = 0; i < strings.size(); i++) {
|
||||
if (isOkWord(strings.get(i))) {
|
||||
Set<Character> c = charsInWord(strings.get(i));
|
||||
int size1 = chars.size();
|
||||
int size2 = c.size();
|
||||
chars.addAll(c);
|
||||
if (size1 + size2 != chars.size()) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
boolean isOkWord(StringBuilder stringBuilder) {
|
||||
Set<Character> chars = new HashSet<>();
|
||||
char prev = stringBuilder.charAt(0);
|
||||
chars.add(prev);
|
||||
for (int i = 1; i < stringBuilder.length(); i++) {
|
||||
while (i < stringBuilder.length() && stringBuilder.charAt(i) == prev) {
|
||||
i++;
|
||||
}
|
||||
if (i >= stringBuilder.length()) {
|
||||
break;
|
||||
}
|
||||
if (!chars.contains(stringBuilder.charAt(i))) {
|
||||
chars.add(stringBuilder.charAt(i));
|
||||
prev = stringBuilder.charAt(i);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Set<Character> charsInWord(StringBuilder stringBuilder) {
|
||||
Set<Character> chars = new HashSet<>();
|
||||
char prev = stringBuilder.charAt(0);
|
||||
chars.add(prev);
|
||||
for (int i = 1; i < stringBuilder.length(); i++) {
|
||||
while (i < stringBuilder.length() && stringBuilder.charAt(i) == prev) {
|
||||
i++;
|
||||
}
|
||||
if (i >= stringBuilder.length()) {
|
||||
break;
|
||||
}
|
||||
if (!chars.contains(stringBuilder.charAt(i))) {
|
||||
chars.add(stringBuilder.charAt(i));
|
||||
} else {
|
||||
return new TreeSet<>();
|
||||
}
|
||||
}
|
||||
return chars;
|
||||
}
|
||||
}
|
40
archive/2016.08/2016.08.04 - unsorted/Sazanka2N.task
Normal file
40
archive/2016.08/2016.08.04 - unsorted/Sazanka2N.task
Normal file
@@ -0,0 +1,40 @@
|
||||
9 Sazanka2N
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
3
|
||||
0
|
||||
14 4
|
||||
abab
|
||||
bb
|
||||
bc
|
||||
k
|
||||
-1
|
||||
1
|
||||
1
|
||||
6 1
|
||||
abab
|
||||
-1
|
||||
1
|
||||
2
|
||||
9 2
|
||||
abab
|
||||
bb
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
17 chelper.Sazanka2N
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.04
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
69
archive/2016.08/2016.08.17 - unsorted/Slerk.java
Normal file
69
archive/2016.08/2016.08.17 - unsorted/Slerk.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class Slerk {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
// int n = in.nextInt();
|
||||
for (int n = 1; n <= 1000; n++) {
|
||||
f(n, out);
|
||||
}
|
||||
}
|
||||
|
||||
void f(int n, OutputWriter out) {
|
||||
int[] yearMonthDay = {1, 1, 1};
|
||||
if (n > 220) {
|
||||
n -= 220;
|
||||
yearMonthDay[0] += 12;
|
||||
yearMonthDay[0] += (n / 66);
|
||||
n %= 66;
|
||||
if (n == 0) {
|
||||
yearMonthDay[0] -= 1;
|
||||
yearMonthDay[1] = 12;
|
||||
yearMonthDay[2] = 11;
|
||||
out.println(yearMonthDay[0] + "/" + yearMonthDay[1] + "/" + yearMonthDay[2]);
|
||||
return;
|
||||
}
|
||||
int cur = 0;
|
||||
for (int i = 1; i < 12; i++) {
|
||||
cur += i;
|
||||
if (n <= cur) {
|
||||
yearMonthDay[1] = i + 1;
|
||||
cur -= i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
n -= cur;
|
||||
yearMonthDay[2] = n;
|
||||
out.println(yearMonthDay[0] + "/" + yearMonthDay[1] + "/" + yearMonthDay[2]);
|
||||
} else {
|
||||
int[] c = {1, 3, 6, 10, 15, 21, 28, 36, 45, 55};
|
||||
yearMonthDay[0] = 3;
|
||||
int cur = 0;
|
||||
for (int i = 0; i < 11; i++) {
|
||||
cur += c[i];
|
||||
if (n > cur) {
|
||||
yearMonthDay[0]++;
|
||||
} else {
|
||||
cur -= c[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
n -= cur;
|
||||
cur = 0;
|
||||
for (int i = 1; i < 12; i++) {
|
||||
cur += i;
|
||||
if (n <= cur) {
|
||||
yearMonthDay[1] = i + 1;
|
||||
cur -= i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
n -= cur;
|
||||
yearMonthDay[2] = n;
|
||||
out.println(yearMonthDay[0] + "/" + yearMonthDay[1] + "/" + yearMonthDay[2]);
|
||||
}
|
||||
}
|
||||
}
|
1044
archive/2016.08/2016.08.17 - unsorted/Slerk.task
Normal file
1044
archive/2016.08/2016.08.17 - unsorted/Slerk.task
Normal file
File diff suppressed because it is too large
Load Diff
39
archive/2016.08/2016.08.27 - unsorted/Hanoi.java
Normal file
39
archive/2016.08/2016.08.27 - unsorted/Hanoi.java
Normal file
@@ -0,0 +1,39 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class Hanoi {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int[] a = new int[n];
|
||||
|
||||
String s = in.nextString();
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i] = s.charAt(i) - 'A';
|
||||
}
|
||||
|
||||
for (int i = n - 1; i >= 0; i--) {
|
||||
if (a[i] == 2) {
|
||||
out.println("NO");
|
||||
return;
|
||||
}
|
||||
|
||||
if (a[i] == 1) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (a[j] < 2) {
|
||||
a[j] = (1 + a[j]) % 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (a[j] > 1) {
|
||||
a[j] = 1 + a[j] % 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.println("YES");
|
||||
}
|
||||
}
|
21
archive/2016.08/2016.08.27 - unsorted/Hanoi.task
Normal file
21
archive/2016.08/2016.08.27 - unsorted/Hanoi.task
Normal file
@@ -0,0 +1,21 @@
|
||||
5 Hanoi
|
||||
6 SINGLE
|
||||
6 CUSTOM
|
||||
9 input.txt
|
||||
6 CUSTOM
|
||||
10 output.txt
|
||||
0
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.Hanoi
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.27
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
9
archive/2016.08/2016.08.31 - unsorted/SnarkA.java
Normal file
9
archive/2016.08/2016.08.31 - unsorted/SnarkA.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class SnarkA {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
}
|
||||
}
|
21
archive/2016.08/2016.08.31 - unsorted/SnarkA.task
Normal file
21
archive/2016.08/2016.08.31 - unsorted/SnarkA.task
Normal file
@@ -0,0 +1,21 @@
|
||||
6 SnarkA
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
0
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
14 chelper.SnarkA
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.31
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
138
archive/2016.08/2016.08.31 - unsorted/SnarkB.java
Normal file
138
archive/2016.08/2016.08.31 - unsorted/SnarkB.java
Normal file
@@ -0,0 +1,138 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class SnarkB {
|
||||
|
||||
int[][] directions = {
|
||||
{0, 1},
|
||||
{0, -1},
|
||||
{1, 0},
|
||||
{-1, 0}
|
||||
};
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int m = in.nextInt();
|
||||
int N = in.nextInt();
|
||||
int M = in.nextInt();
|
||||
|
||||
int[][] a = new int[n][m];
|
||||
for (int i = 0; i < n; i++) {
|
||||
String s = in.nextString();
|
||||
for (int j = 0; j < m; j++) {
|
||||
if (s.charAt(j) == 'O') {
|
||||
a[i][j] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int mini = n;
|
||||
int minj = n;
|
||||
int maxi = 0;
|
||||
int maxj = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
if (a[i][j] != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mini = Math.min(mini, i);
|
||||
minj = Math.min(minj, j);
|
||||
maxi = Math.max(maxi, i);
|
||||
maxj = Math.max(maxj, j);
|
||||
}
|
||||
}
|
||||
|
||||
int n2 = maxi - mini + 1;
|
||||
int m2 = maxj - minj + 1;
|
||||
|
||||
int[][] a2 = new int[n2][m2];
|
||||
|
||||
for (int i = 0; i < n2; i++) {
|
||||
for (int j = 0; j < m2; j++) {
|
||||
a2[i][j] = a[i + mini][j + minj];
|
||||
}
|
||||
}
|
||||
|
||||
int[][] A = new int[N][M];
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
String s = in.nextString();
|
||||
for (int j = 0; j < M; j++) {
|
||||
if (s.charAt(j) == 'O') {
|
||||
A[i][j] = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int ans = 0;
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
for (int j = 0; j < M; j++) {
|
||||
boolean bounds = true;
|
||||
for (int factor = 1; factor < 1000 && bounds; factor++) {
|
||||
boolean ok = true;
|
||||
|
||||
for (int ii = 0; ii < n2 * factor && ok && bounds; ii++) {
|
||||
for (int jj = 0; jj < m2 * factor && ok && bounds; jj++) {
|
||||
if (ii + i >= N || jj + j >= M) {
|
||||
bounds = false;
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
int io = ii / factor;
|
||||
int jo = jj / factor;
|
||||
|
||||
if (a2[io][jo] != 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (A[ii + i][jj + j] != 1) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
for (int[] direction : directions) {
|
||||
int ii2 = ii + direction[0];
|
||||
int jj2 = jj + direction[1];
|
||||
|
||||
int val1 = -1;
|
||||
int val2 = -1;
|
||||
|
||||
if (ii2 + i < 0 || jj2 + j < 0 || ii2 + i >= N || jj2 + j >= M) {
|
||||
val2 = 0;
|
||||
} else {
|
||||
val2 = A[ii2 + i][jj2 + j];
|
||||
}
|
||||
|
||||
int io2 = ii2 / factor;
|
||||
int jo2 = jj2 / factor;
|
||||
|
||||
if (io2 < 0 || jo2 < 0 || io2 >= n2 || jo2 >= m2 || ii2 < 0 || jj2 < 0) {
|
||||
val1 = 0;
|
||||
} else {
|
||||
val1 = a2[io2][jo2];
|
||||
}
|
||||
|
||||
if (val1 != val2) {
|
||||
ok = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
ans++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
out.println(ans);
|
||||
}
|
||||
}
|
72
archive/2016.08/2016.08.31 - unsorted/SnarkB.task
Normal file
72
archive/2016.08/2016.08.31 - unsorted/SnarkB.task
Normal file
@@ -0,0 +1,72 @@
|
||||
6 SnarkB
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
3
|
||||
0
|
||||
91 3 3 9 7
|
||||
.OO
|
||||
OOO
|
||||
.O.
|
||||
..OOOO.
|
||||
..OOOO.
|
||||
OOOOOO.
|
||||
OOOOOO.
|
||||
..OO...
|
||||
..OO...
|
||||
...OO..
|
||||
..OOO..
|
||||
...O...
|
||||
1 0
|
||||
1
|
||||
1
|
||||
100 3 3 10 7
|
||||
.OO
|
||||
OOO
|
||||
.O.
|
||||
..OOOO.
|
||||
..OOOO.
|
||||
OOOOOO.
|
||||
OOOOOO.
|
||||
..OO...
|
||||
..OO...
|
||||
.......
|
||||
...O...
|
||||
..OOO..
|
||||
...OO..
|
||||
1 1
|
||||
1
|
||||
2
|
||||
114 4 3 10 8
|
||||
.OO
|
||||
OOO
|
||||
.O.
|
||||
...
|
||||
.OO.....
|
||||
OOO...OO
|
||||
.O...OOO
|
||||
......O.
|
||||
..OOOO..
|
||||
..OOOO..
|
||||
OOOOOO..
|
||||
OOOOOO..
|
||||
..OO....
|
||||
..OO....
|
||||
1 3
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
14 chelper.SnarkB
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.31
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
29
archive/2016.08/2016.08.31 - unsorted/SnarkD.java
Normal file
29
archive/2016.08/2016.08.31 - unsorted/SnarkD.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class SnarkD {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
double l = in.nextInt() / 2.0;
|
||||
double r = in.nextInt();
|
||||
|
||||
if (r < l) {
|
||||
out.println(Math.PI * r * r);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (r > l * Math.sqrt(2)) {
|
||||
out.println(4 * l * l);
|
||||
continue;
|
||||
}
|
||||
|
||||
double a = Math.acos(1.0 * l / r);
|
||||
|
||||
out.println((Math.PI - 4 * a) * r * r + l * Math.sin(a) * r * 4);
|
||||
}
|
||||
}
|
||||
}
|
33
archive/2016.08/2016.08.31 - unsorted/SnarkD.task
Normal file
33
archive/2016.08/2016.08.31 - unsorted/SnarkD.task
Normal file
@@ -0,0 +1,33 @@
|
||||
6 SnarkD
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
2
|
||||
0
|
||||
11 2
|
||||
2 2
|
||||
42 24
|
||||
12 4.00
|
||||
1621.20
|
||||
1
|
||||
1
|
||||
5 1
|
||||
1 3
|
||||
1 1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
14 chelper.SnarkD
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.31
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
28
archive/2016.08/2016.08.31 - unsorted/SnarkE.java
Normal file
28
archive/2016.08/2016.08.31 - unsorted/SnarkE.java
Normal file
@@ -0,0 +1,28 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class SnarkE {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
|
||||
boolean[][] a = new boolean[n][n];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
String s = in.nextString();
|
||||
for (int j = 0; j < n; j++) {
|
||||
a[i][j] = s.charAt(j) == '1';
|
||||
}
|
||||
}
|
||||
|
||||
int[][] dpi = new int[n][n];
|
||||
int[][] dpj = new int[n][n];
|
||||
|
||||
for (int i = n - 1; i >= 0; i--) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
dpi[i][j] = a[i][j] ? 1 : 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
21
archive/2016.08/2016.08.31 - unsorted/SnarkE.task
Normal file
21
archive/2016.08/2016.08.31 - unsorted/SnarkE.task
Normal file
@@ -0,0 +1,21 @@
|
||||
6 SnarkE
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
0
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
14 chelper.SnarkE
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.08.31
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
73
archive/2016.09/2016.09.19 - unsorted/L.java
Normal file
73
archive/2016.09/2016.09.19 - unsorted/L.java
Normal file
@@ -0,0 +1,73 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class L {
|
||||
int[] bfs(List<List<Integer>> edges, int from) {
|
||||
int n = edges.size();
|
||||
int[] res = new int[n];
|
||||
Arrays.fill(res, n + 100);
|
||||
res[from] = 0;
|
||||
|
||||
boolean[] visited = new boolean[n];
|
||||
visited[from] = true;
|
||||
|
||||
Queue<Integer> queue = new LinkedList<>();
|
||||
queue.add(from);
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
int a = queue.poll();
|
||||
for (int b : edges.get(a)) {
|
||||
if (!visited[b]) {
|
||||
res[b] = res[a] + 1;
|
||||
visited[b] = true;
|
||||
queue.add(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt() + 1;
|
||||
int m = in.nextInt();
|
||||
|
||||
int a = in.nextInt();
|
||||
int b = in.nextInt();
|
||||
|
||||
List<List<Integer>> edges1 = new ArrayList<>();
|
||||
List<List<Integer>> edges2 = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
edges1.add(new ArrayList<>());
|
||||
edges2.add(new ArrayList<>());
|
||||
}
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
int v1 = in.nextInt();
|
||||
int v2 = in.nextInt();
|
||||
edges1.get(v1).add(v2);
|
||||
edges2.get(v2).add(v1);
|
||||
}
|
||||
|
||||
int[] toPivot = bfs(edges1, 0);
|
||||
int[] fromA = bfs(edges2, a);
|
||||
int[] fromB = bfs(edges2, b);
|
||||
|
||||
int res = n + 100;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
res = Math.min(res, toPivot[i] + fromA[i] + fromB[i]);
|
||||
}
|
||||
|
||||
out.println(res);
|
||||
}
|
||||
}
|
43
archive/2016.09/2016.09.19 - unsorted/L.task
Normal file
43
archive/2016.09/2016.09.19 - unsorted/L.task
Normal file
@@ -0,0 +1,43 @@
|
||||
1 L
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
2
|
||||
0
|
||||
39 6 8 4 6
|
||||
0 1
|
||||
0 2
|
||||
1 2
|
||||
1 5
|
||||
2 3
|
||||
2 4
|
||||
3 6
|
||||
5 6
|
||||
1 4
|
||||
1
|
||||
1
|
||||
31 4 6 3 4
|
||||
0 1
|
||||
0 2
|
||||
1 3
|
||||
2 4
|
||||
3 4
|
||||
4 3
|
||||
1 3
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.L
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.09.19
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
78
archive/2016.09/2016.09.19 - unsorted/M.java
Normal file
78
archive/2016.09/2016.09.19 - unsorted/M.java
Normal file
@@ -0,0 +1,78 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class M {
|
||||
boolean ask(InputReader in, OutputWriter out, int i, int j) {
|
||||
out.println("? " + i + " " + j);
|
||||
out.flush();
|
||||
return in.nextLine().charAt(0) == '<';
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = Integer.parseInt(in.nextLine());
|
||||
|
||||
int m = Integer.highestOneBit(n) * 2;
|
||||
int[] a = new int[2 * m];
|
||||
Arrays.fill(a, -1);
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[m + i] = i + 1;
|
||||
}
|
||||
|
||||
for (int i = m - 1; i >= 1; i--) {
|
||||
int c1 = a[2 * i];
|
||||
int c2 = a[2 * i + 1];
|
||||
|
||||
if (c2 == -1 || c1 == -1) {
|
||||
a[i] = c1;
|
||||
continue;
|
||||
}
|
||||
|
||||
a[i] = ask(in, out, c1, c2) ? c2 : c1;
|
||||
}
|
||||
|
||||
int p = 1;
|
||||
|
||||
Queue<Integer> candidates = new LinkedList<>();
|
||||
|
||||
while (true) {
|
||||
int c1 = p * 2;
|
||||
int c2 = p * 2 + 1;
|
||||
|
||||
if (c1 >= 2 * m || c2 >= 2 * m) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (a[c2] == a[p]) {
|
||||
int t = c1;
|
||||
c1 = c2;
|
||||
c2 = t;
|
||||
}
|
||||
|
||||
if (a[c2] != -1) {
|
||||
candidates.add(a[c2]);
|
||||
}
|
||||
p = c1;
|
||||
}
|
||||
|
||||
while (candidates.size() > 1) {
|
||||
int a1 = candidates.poll();
|
||||
int a2 = candidates.poll();
|
||||
|
||||
if (ask(in, out, a1, a2)) {
|
||||
candidates.add(a2);
|
||||
} else {
|
||||
candidates.add(a1);
|
||||
}
|
||||
}
|
||||
|
||||
out.println("! " + candidates.poll());
|
||||
out.flush();
|
||||
}
|
||||
}
|
21
archive/2016.09/2016.09.19 - unsorted/M.task
Normal file
21
archive/2016.09/2016.09.19 - unsorted/M.task
Normal file
@@ -0,0 +1,21 @@
|
||||
1 M
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
0
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.M
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.09.19
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
9
archive/2016.09/2016.09.20 - unsorted/M2.java
Normal file
9
archive/2016.09/2016.09.20 - unsorted/M2.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class M2 {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
}
|
||||
}
|
21
archive/2016.09/2016.09.20 - unsorted/M2.task
Normal file
21
archive/2016.09/2016.09.20 - unsorted/M2.task
Normal file
@@ -0,0 +1,21 @@
|
||||
2 M2
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
0
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
10 chelper.M2
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.09.20
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,39 @@
|
||||
16 A - Jumping Ball
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
3
|
||||
0
|
||||
7 4
|
||||
<<><
|
||||
|
||||
1 2
|
||||
1
|
||||
1
|
||||
8 5
|
||||
>>>>>
|
||||
|
||||
1 5
|
||||
1
|
||||
2
|
||||
7 4
|
||||
>><<
|
||||
|
||||
1 0
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskA
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.10.22
|
||||
15 Canada Cup 2016
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,45 @@
|
||||
21 B - Food on the Plane
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
4
|
||||
0
|
||||
3 1f
|
||||
|
||||
2 1
|
||||
|
||||
1
|
||||
1
|
||||
3 2d
|
||||
|
||||
3 10
|
||||
|
||||
1
|
||||
2
|
||||
3 4a
|
||||
|
||||
3 11
|
||||
|
||||
1
|
||||
3
|
||||
3 5e
|
||||
|
||||
3 18
|
||||
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskB
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.10.22
|
||||
15 Canada Cup 2016
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,34 @@
|
||||
15 C - Hidden Word
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
2
|
||||
0
|
||||
28 ABCDEFGHIJKLMNOPQRSGTUVWXYZ
|
||||
|
||||
28 YXWVUTGHIJKLM
|
||||
ZABCDEFSRQPON
|
||||
|
||||
1
|
||||
1
|
||||
28 BUVTYZFQSNRIWOXXGJLKACPEMDH
|
||||
|
||||
11 Impossible
|
||||
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskC
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.10.22
|
||||
15 Canada Cup 2016
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,67 @@
|
||||
20 D - Contest Balloons
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
4
|
||||
0
|
||||
57 8
|
||||
20 1000
|
||||
32 37
|
||||
40 1000
|
||||
45 50
|
||||
16 16
|
||||
16 16
|
||||
14 1000
|
||||
2 1000
|
||||
|
||||
2 3
|
||||
|
||||
1
|
||||
1
|
||||
30 7
|
||||
4 4
|
||||
4 4
|
||||
4 4
|
||||
4 4
|
||||
4 4
|
||||
4 4
|
||||
5 5
|
||||
|
||||
2 2
|
||||
|
||||
1
|
||||
2
|
||||
145 7
|
||||
14000000003 1000000000000000000
|
||||
81000000000 88000000000
|
||||
5000000000 7000000000
|
||||
15000000000 39000000000
|
||||
46000000000 51000000000
|
||||
0 1000000000
|
||||
0 0
|
||||
|
||||
2 2
|
||||
|
||||
1
|
||||
3
|
||||
11 2
|
||||
0 0
|
||||
10 10
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskD
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.10.22
|
||||
15 Canada Cup 2016
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,46 @@
|
||||
18 E - Too Much Money
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
2
|
||||
0
|
||||
11 12
|
||||
3
|
||||
5
|
||||
3
|
||||
4
|
||||
|
||||
2 5
|
||||
|
||||
1
|
||||
1
|
||||
25 50
|
||||
8
|
||||
1
|
||||
2
|
||||
4
|
||||
8
|
||||
16
|
||||
37
|
||||
37
|
||||
37
|
||||
|
||||
14 Greed is good
|
||||
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskE
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.10.22
|
||||
15 Canada Cup 2016
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,44 @@
|
||||
17 F - Family Photos
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
3
|
||||
0
|
||||
20 2
|
||||
12 3 4 7
|
||||
1 15 9 1
|
||||
|
||||
2 1
|
||||
|
||||
1
|
||||
1
|
||||
20 2
|
||||
5 4 8 8
|
||||
4 12 14 0
|
||||
|
||||
2 4
|
||||
|
||||
1
|
||||
2
|
||||
12 1
|
||||
0 10 0 10
|
||||
|
||||
4 -10
|
||||
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskF
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.10.22
|
||||
15 Canada Cup 2016
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,47 @@
|
||||
22 G - Messages on a Tree
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
3
|
||||
0
|
||||
29 6 3
|
||||
0 1 2 3 2 5
|
||||
4 6
|
||||
6 9
|
||||
5 11
|
||||
|
||||
9 14 13 11
|
||||
1
|
||||
1
|
||||
18 3 2
|
||||
0 1 1
|
||||
2 1
|
||||
3 1
|
||||
|
||||
4 5 3
|
||||
1
|
||||
2
|
||||
32 8 3
|
||||
0 1 1 2 3 3 4 5
|
||||
6 1
|
||||
8 2
|
||||
4 5
|
||||
|
||||
7 7 6 11
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskG
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.10.22
|
||||
15 Canada Cup 2016
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
31
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskA.java
Normal file
31
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskA.java
Normal file
@@ -0,0 +1,31 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskA {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
String s = in.nextString();
|
||||
|
||||
int c = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (s.charAt(i) == '<') {
|
||||
c++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (s.charAt(n - i - 1) == '>') {
|
||||
c++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
out.println(c);
|
||||
}
|
||||
}
|
36
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskB.java
Normal file
36
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskB.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package chelper;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskB {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
String s = in.nextString();
|
||||
|
||||
long n = Long.parseLong(s.substring(0, s.length() - 1)) - 1;
|
||||
int p = s.charAt(s.length() - 1);
|
||||
|
||||
BigInteger ans = BigInteger.valueOf(n / 4).multiply(BigInteger.valueOf(16));
|
||||
|
||||
long c = 0;
|
||||
|
||||
switch (p) {
|
||||
case 'a': c += 4; break;
|
||||
case 'b': c += 5; break;
|
||||
case 'c': c += 6; break;
|
||||
case 'd': c += 3; break;
|
||||
case 'e': c += 2; break;
|
||||
case 'f': c += 1; break;
|
||||
}
|
||||
|
||||
if ((n % 4) % 2 == 1) {
|
||||
c += 7;
|
||||
}
|
||||
|
||||
ans = ans.add(BigInteger.valueOf(c));
|
||||
|
||||
out.println(ans);
|
||||
}
|
||||
}
|
92
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskC.java
Normal file
92
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskC.java
Normal file
@@ -0,0 +1,92 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskC {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
char[] ch = in.nextString().toCharArray();
|
||||
int[] a = new int[26];
|
||||
|
||||
char dup = 0;
|
||||
int[] fpos = new int[26];
|
||||
Arrays.fill(fpos, -1);
|
||||
|
||||
for (int i = 0; i < 27; i++) {
|
||||
char c = ch[i];
|
||||
if (fpos[c - 'A'] == -1) {
|
||||
fpos[c - 'A'] = i;
|
||||
}
|
||||
a[c - 'A']++;
|
||||
if (a[c - 'A'] >= 2) {
|
||||
if (dup == 0) {
|
||||
dup = c;
|
||||
} else {
|
||||
out.println("Impossible");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
List<Character> pre = new ArrayList<>();
|
||||
List<Character> mid = new ArrayList<>();
|
||||
List<Character> post = new ArrayList<>();
|
||||
|
||||
int st = 0;
|
||||
|
||||
for (char c : ch) {
|
||||
if (c == dup) {
|
||||
st++;
|
||||
} else {
|
||||
if (st == 0) {
|
||||
pre.add(c);
|
||||
}
|
||||
if (st == 1) {
|
||||
mid.add(c);
|
||||
}
|
||||
if (st == 2) {
|
||||
post.add(c);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (mid.size() == 0) {
|
||||
out.println("Impossible");
|
||||
return;
|
||||
}
|
||||
|
||||
int pos = 13 - mid.size() / 2 - 1;
|
||||
|
||||
char[] res = new char[26];
|
||||
|
||||
res[pos] = dup;
|
||||
|
||||
int strpos = fpos[dup - 'A'];
|
||||
|
||||
for (int i = 0; i < 27; i++) {
|
||||
char c = ch[strpos];
|
||||
strpos = (strpos + 1) % 27;
|
||||
if (c == dup) {
|
||||
continue;
|
||||
}
|
||||
pos = (pos + 1) % 26;
|
||||
res[pos] = c;
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < 13; i++) {
|
||||
out.print(res[i]);
|
||||
}
|
||||
out.println();
|
||||
|
||||
for (int i = 0; i < 13; i++) {
|
||||
out.print(res[25 - i]);
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
}
|
136
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskD.java
Normal file
136
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskD.java
Normal file
@@ -0,0 +1,136 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskD {
|
||||
class Team implements Comparable<Team> {
|
||||
public final long score;
|
||||
public final long weight;
|
||||
public final long leeway;
|
||||
private final int index;
|
||||
|
||||
public Team(int index, long score, long weight) {
|
||||
this.index = index;
|
||||
this.score = score;
|
||||
this.weight = weight;
|
||||
leeway = weight - score + 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Team o) {
|
||||
return Long.compare(leeway, o.leeway);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Team team = (Team) o;
|
||||
|
||||
if (score != team.score) return false;
|
||||
if (weight != team.weight) return false;
|
||||
if (leeway != team.leeway) return false;
|
||||
return index == team.index;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (int) (score ^ score >>> 32);
|
||||
result = 31 * result + (int) (weight ^ weight >>> 32);
|
||||
result = 31 * result + (int) (leeway ^ leeway >>> 32);
|
||||
result = 31 * result + index;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt() - 1;
|
||||
long ourScore = in.nextLong();
|
||||
long ourWeight = in.nextLong();
|
||||
List<Team> teams = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
Team team = new Team(i, in.nextLong(), in.nextLong());
|
||||
teams.add(team);
|
||||
}
|
||||
|
||||
Collections.sort(teams);
|
||||
|
||||
List<Team> left = new ArrayList<>();
|
||||
List<Team> right = new ArrayList<>();
|
||||
|
||||
for (Team team : teams) {
|
||||
if (team.score > ourScore) {
|
||||
left.add(team);
|
||||
} else {
|
||||
right.add(team);
|
||||
}
|
||||
}
|
||||
|
||||
Collections.sort(right, new Comparator<Team>() {
|
||||
@Override
|
||||
public int compare(Team o1, Team o2) {
|
||||
return -Long.compare(o1.score, o2.score);
|
||||
}
|
||||
});
|
||||
|
||||
long ans = left.size() + 1;
|
||||
|
||||
SortedMap<Long, Long> leftMap = new TreeMap<>();
|
||||
|
||||
for (Team team : left) {
|
||||
if (!leftMap.containsKey(team.leeway)) {
|
||||
leftMap.put(team.leeway, 0L);
|
||||
}
|
||||
leftMap.put(team.leeway, leftMap.get(team.leeway) + 1);
|
||||
}
|
||||
|
||||
int rightPos = 0;
|
||||
int ourPlace = left.size() + 1;
|
||||
|
||||
while (!leftMap.isEmpty()) {
|
||||
long minLeeway = leftMap.firstKey();
|
||||
ourScore -= minLeeway;
|
||||
if (ourScore < 0) {
|
||||
break;
|
||||
}
|
||||
long minVal = leftMap.get(minLeeway) - 1;
|
||||
if (minVal == 0) {
|
||||
leftMap.remove(minLeeway);
|
||||
} else {
|
||||
leftMap.put(minLeeway, minVal);
|
||||
}
|
||||
ourPlace--;
|
||||
|
||||
while (rightPos < right.size()) {
|
||||
Team team = right.get(rightPos);
|
||||
if (team.score > ourScore) {
|
||||
if (!leftMap.containsKey(team.leeway)) {
|
||||
leftMap.put(team.leeway, 0L);
|
||||
}
|
||||
leftMap.put(team.leeway, leftMap.get(team.leeway) + 1);
|
||||
rightPos++;
|
||||
ourPlace++;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ans = Math.min(ans, ourPlace);
|
||||
}
|
||||
|
||||
out.println(ans);
|
||||
}
|
||||
}
|
9
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskE.java
Normal file
9
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskE.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskE {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
}
|
||||
}
|
9
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskF.java
Normal file
9
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskF.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskF {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
}
|
||||
}
|
9
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskG.java
Normal file
9
archive/2016.10/2016.10.22 - Canada Cup 2016/TaskG.java
Normal file
@@ -0,0 +1,9 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskG {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
}
|
||||
}
|
42
archive/2016.12/2016.12.05 - unsorted/Day5.java
Normal file
42
archive/2016.12/2016.12.05 - unsorted/Day5.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package chelper;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class Day5 {
|
||||
public static String toHex(byte[] bytes) {
|
||||
BigInteger bi = new BigInteger(1, bytes);
|
||||
return String.format("%0" + (bytes.length << 1) + "x", bi);
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
String s = in.nextString();
|
||||
|
||||
char[] res = new char[8];
|
||||
int filled = 0;
|
||||
|
||||
for (int i = 0; true; i++) {
|
||||
try {
|
||||
String hash = toHex(MessageDigest.getInstance("MD5").digest((s + Integer.toString(i)).getBytes()));
|
||||
if (hash.startsWith("00000")) {
|
||||
int pos = hash.charAt(5) - '0';
|
||||
|
||||
if (pos >= 0 && pos < 8 && res[pos] == 0) {
|
||||
res[pos] = hash.charAt(6);
|
||||
filled += 1;
|
||||
System.out.println(filled);
|
||||
System.out.println(new String(res));
|
||||
System.out.println();
|
||||
}
|
||||
}
|
||||
} catch (NoSuchAlgorithmException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
25
archive/2016.12/2016.12.05 - unsorted/Day5.task
Normal file
25
archive/2016.12/2016.12.05 - unsorted/Day5.task
Normal file
@@ -0,0 +1,25 @@
|
||||
4 Day5
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
8 wtnhxymk
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
12 chelper.Day5
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2016.12.05
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
29
archive/2017.01/2017.01.07 - unsorted/A.java
Normal file
29
archive/2017.01/2017.01.07 - unsorted/A.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class A {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
|
||||
List<Integer> res = new ArrayList<>();
|
||||
|
||||
if (n % 2 == 1) {
|
||||
res.add(3);
|
||||
n -= 3;
|
||||
}
|
||||
|
||||
for (int i = 0; i < n / 2; i++) {
|
||||
res.add(2);
|
||||
}
|
||||
|
||||
out.println(res.size());
|
||||
for (int i : res) {
|
||||
out.print(i + " ");
|
||||
}
|
||||
}
|
||||
}
|
31
archive/2017.01/2017.01.07 - unsorted/A.task
Normal file
31
archive/2017.01/2017.01.07 - unsorted/A.task
Normal file
@@ -0,0 +1,31 @@
|
||||
1 A
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
2
|
||||
0
|
||||
1 5
|
||||
5 2
|
||||
2 3
|
||||
1
|
||||
1
|
||||
1 6
|
||||
7 3
|
||||
2 2 2
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.A
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.01.07
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
25
archive/2017.01/2017.01.07 - unsorted/B.java
Normal file
25
archive/2017.01/2017.01.07 - unsorted/B.java
Normal file
@@ -0,0 +1,25 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class B {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
String s = in.nextString();
|
||||
Set<Integer> set = new HashSet<>();
|
||||
|
||||
for (char c : s.toCharArray()) {
|
||||
set.add((int)c);
|
||||
}
|
||||
|
||||
if (set.size() != n) {
|
||||
out.println("NO");
|
||||
} else {
|
||||
out.println("YES");
|
||||
}
|
||||
}
|
||||
}
|
31
archive/2017.01/2017.01.07 - unsorted/B.task
Normal file
31
archive/2017.01/2017.01.07 - unsorted/B.task
Normal file
@@ -0,0 +1,31 @@
|
||||
1 B
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
2
|
||||
0
|
||||
5 3
|
||||
abc
|
||||
3 YES
|
||||
1
|
||||
1
|
||||
5 3
|
||||
aaa
|
||||
2 NO
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.B
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.01.07
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
69
archive/2017.01/2017.01.07 - unsorted/C.java
Normal file
69
archive/2017.01/2017.01.07 - unsorted/C.java
Normal file
@@ -0,0 +1,69 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class C {
|
||||
class Point {
|
||||
final int x;
|
||||
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;
|
||||
|
||||
if (x != point.x) return false;
|
||||
return y == point.y;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = x;
|
||||
result = 31 * result + y;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Point sub(Point p) {
|
||||
return new Point(x - p.x, y - p.y);
|
||||
}
|
||||
|
||||
public Point add(Point p) {
|
||||
return new Point(x + p.x, y + p.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + " " + y;
|
||||
}
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
Point a = new Point(in.nextInt(), in.nextInt());
|
||||
Point b = new Point(in.nextInt(), in.nextInt());
|
||||
Point c = new Point(in.nextInt(), in.nextInt());
|
||||
|
||||
Set<Point> points = new HashSet<>();
|
||||
|
||||
points.add(a.add(b.sub(a)).add(c.sub(a)));
|
||||
points.add(b.add(a.sub(b)).add(c.sub(b)));
|
||||
points.add(c.add(a.sub(c)).add(b.sub(c)));
|
||||
|
||||
out.println(points.size());
|
||||
|
||||
for (Point point : points) {
|
||||
out.println(point);
|
||||
}
|
||||
}
|
||||
}
|
30
archive/2017.01/2017.01.07 - unsorted/C.task
Normal file
30
archive/2017.01/2017.01.07 - unsorted/C.task
Normal file
@@ -0,0 +1,30 @@
|
||||
1 C
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
11 0 0
|
||||
1 0
|
||||
0 1
|
||||
15 3
|
||||
1 -1
|
||||
-1 1
|
||||
1 1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.C
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.01.07
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
38
archive/2017.01/2017.01.07 - unsorted/E.java
Normal file
38
archive/2017.01/2017.01.07 - unsorted/E.java
Normal file
@@ -0,0 +1,38 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class E {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
long n = in.nextLong();
|
||||
long m = in.nextLong();
|
||||
|
||||
out.println("? 0 0");
|
||||
out.flush();
|
||||
|
||||
long dist1 = in.nextLong();
|
||||
|
||||
long dist2 = n + m - dist1;
|
||||
|
||||
if (dist1 <= dist2) {
|
||||
out.println("? " + dist1 + " 0");
|
||||
out.flush();
|
||||
|
||||
long dist3 = in.nextLong() / 2;
|
||||
long x = dist1 - dist3;
|
||||
long y = dist3;
|
||||
out.println("! " + x + " " + y);
|
||||
out.flush();
|
||||
} else {
|
||||
out.println("? " + (n - dist2) + " " + m);
|
||||
out.flush();
|
||||
|
||||
long dist3 = in.nextLong() / 2;
|
||||
long x = (n - dist2) + dist3;
|
||||
long y = m - dist3;
|
||||
out.println("! " + x + " " + y);
|
||||
out.flush();
|
||||
}
|
||||
}
|
||||
}
|
25
archive/2017.01/2017.01.07 - unsorted/E.task
Normal file
25
archive/2017.01/2017.01.07 - unsorted/E.task
Normal file
@@ -0,0 +1,25 @@
|
||||
1 E
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
3 3 3
|
||||
0
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.E
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.01.07
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
87
archive/2017.01/2017.01.07 - unsorted/F.java
Normal file
87
archive/2017.01/2017.01.07 - unsorted/F.java
Normal file
@@ -0,0 +1,87 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class F {
|
||||
class Point {
|
||||
final int x;
|
||||
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;
|
||||
|
||||
if (x != point.x) return false;
|
||||
return y == point.y;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = x;
|
||||
result = 31 * result + y;
|
||||
return result;
|
||||
}
|
||||
|
||||
public Point sub(Point p) {
|
||||
return new Point(x - p.x, y - p.y);
|
||||
}
|
||||
|
||||
public Point add(Point p) {
|
||||
return new Point(x + p.x, y + p.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return x + " " + y;
|
||||
}
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int m = in.nextInt();
|
||||
|
||||
boolean[][] a = new boolean[n][m];
|
||||
|
||||
Map<Integer, Point> locations = new HashMap<>();
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
int t = in.nextInt();
|
||||
locations.put(t, new Point(i, j));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < n * m; i++) {
|
||||
int t = in.nextInt();
|
||||
Point p = locations.get(t);
|
||||
|
||||
int x = p.x;
|
||||
int y = p.y;
|
||||
|
||||
if (x < n - 1) {
|
||||
if (!a[x + 1][y]) {
|
||||
out.println("NO");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
a[x][y] = true;
|
||||
}
|
||||
|
||||
out.println("YES");
|
||||
}
|
||||
}
|
42
archive/2017.01/2017.01.07 - unsorted/F.task
Normal file
42
archive/2017.01/2017.01.07 - unsorted/F.task
Normal file
@@ -0,0 +1,42 @@
|
||||
1 F
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
3
|
||||
0
|
||||
19 2 2
|
||||
1 2
|
||||
3 4
|
||||
3 4 1 2
|
||||
3 YES
|
||||
1
|
||||
1
|
||||
19 2 2
|
||||
1 2
|
||||
3 4
|
||||
3 1 4 2
|
||||
3 YES
|
||||
1
|
||||
2
|
||||
27 2 3
|
||||
1 2 3
|
||||
4 5 6
|
||||
6 1 5 2 4 3
|
||||
2 NO
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.F
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.01.07
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
99
archive/2017.01/2017.01.07 - unsorted/I.java
Normal file
99
archive/2017.01/2017.01.07 - unsorted/I.java
Normal file
@@ -0,0 +1,99 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class I {
|
||||
int n;
|
||||
int[] a, b;
|
||||
Map<Integer, Integer> l1, l2;
|
||||
|
||||
void swap(int i, int j) {
|
||||
int p1 = l1.get(a[i]);
|
||||
int p2 = l2.get(a[i]);
|
||||
if (p1 != i) {
|
||||
int c = p1;
|
||||
p1 = p2;
|
||||
p2 = c;
|
||||
}
|
||||
|
||||
int p3 = l1.get(b[j]);
|
||||
int p4 = l2.get(b[j]);
|
||||
if (p3 != n + j) {
|
||||
int c = p3;
|
||||
p3 = p4;
|
||||
p4 = c;
|
||||
}
|
||||
|
||||
l1.put(a[i], n + j);
|
||||
l2.put(a[i], p2);
|
||||
|
||||
l1.put(b[j], i);
|
||||
l2.put(b[j], p4);
|
||||
|
||||
int c = a[i];
|
||||
a[i] = b[j];
|
||||
b[j] = c;
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
n = in.nextInt();
|
||||
a = in.nextIntArray(n);
|
||||
b = in.nextIntArray(n);
|
||||
|
||||
l1 = new HashMap<>();
|
||||
l2 = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (!l1.containsKey(a[i])) {
|
||||
l1.put(a[i], i);
|
||||
} else {
|
||||
l2.put(a[i], i);
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (!l1.containsKey(b[i])) {
|
||||
l1.put(b[i], i + n);
|
||||
} else {
|
||||
l2.put(b[i], i + n);
|
||||
}
|
||||
}
|
||||
|
||||
List<String> actions = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
int t = a[i];
|
||||
|
||||
int p1 = l1.get(t);
|
||||
int p2 = l2.get(t);
|
||||
|
||||
if (p2 < p1) {
|
||||
int c = p1;
|
||||
p1 = p2;
|
||||
p2 = c;
|
||||
}
|
||||
|
||||
if (p2 < n) {
|
||||
swap(p2, i);
|
||||
actions.add((p2 + 1) + " " + (i + 1));
|
||||
} else {
|
||||
p2 -= n;
|
||||
swap(p2, p2);
|
||||
actions.add((p2 + 1) + " " + (p2 + 1));
|
||||
swap(p2, i);
|
||||
actions.add((p2 + 1) + " " + (i + 1));
|
||||
}
|
||||
}
|
||||
|
||||
out.println(actions.size());
|
||||
for (String action : actions) {
|
||||
out.println(action);
|
||||
}
|
||||
}
|
||||
}
|
27
archive/2017.01/2017.01.07 - unsorted/I.task
Normal file
27
archive/2017.01/2017.01.07 - unsorted/I.task
Normal file
@@ -0,0 +1,27 @@
|
||||
1 I
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
13 3
|
||||
1 1 2
|
||||
2 3 3
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.I
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.01.07
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
97
archive/2017.01/2017.01.10 - unsorted/TaskK.java
Normal file
97
archive/2017.01/2017.01.10 - unsorted/TaskK.java
Normal file
@@ -0,0 +1,97 @@
|
||||
package chelper;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskK {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int[] a = new int[n];
|
||||
int[] b = new int[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i] = in.nextInt() - 1;
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
b[i] = in.nextInt() - 1;
|
||||
}
|
||||
int[][] position = new int[2][n];
|
||||
Arrays.fill(position[0], -1);
|
||||
for (int i = 0; i < n; i++) {
|
||||
int x = a[i];
|
||||
if (position[0][x] == -1) {
|
||||
position[0][x] = i;
|
||||
} else {
|
||||
position[1][x] = i;
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < n; i++) {
|
||||
int x = b[i];
|
||||
if (position[0][x] == -1) {
|
||||
position[0][x] = i + n;
|
||||
} else {
|
||||
position[1][x] = i + n;
|
||||
}
|
||||
}
|
||||
List<String> answer = new ArrayList<>();
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (a[i] == b[i]) {
|
||||
continue;
|
||||
}
|
||||
int x = a[i];
|
||||
int pos = position[0][x] == i ? position[1][x] : position[0][x];
|
||||
if (pos < n) {
|
||||
answer.add((pos + 1) + " " + (i + 1));
|
||||
int c = b[i];
|
||||
a[pos] = c;
|
||||
b[i] = x;
|
||||
if (position[0][x] == i) {
|
||||
position[1][x] = i + n;
|
||||
} else {
|
||||
position[0][x] = i + n;
|
||||
}
|
||||
if (position[0][c] == i + n) {
|
||||
position[0][c] = pos;
|
||||
} else {
|
||||
position[1][c] = pos;
|
||||
}
|
||||
} else {
|
||||
pos -= n;
|
||||
answer.add((pos + 1) + " " + (pos + 1));
|
||||
answer.add((pos + 1) + " " + (i + 1));
|
||||
int c = b[i];
|
||||
int d = a[pos];
|
||||
int posx1 = i;
|
||||
int posc = i + n;
|
||||
int posd = pos;
|
||||
int posx2 = pos + n;
|
||||
a[pos] = c;
|
||||
b[i] = x;
|
||||
b[pos] = d;
|
||||
if (position[0][x] == posx1) {
|
||||
position[1][x] = posc;
|
||||
} else {
|
||||
position[0][x] = posc;
|
||||
}
|
||||
if (position[0][c] == posc) {
|
||||
position[0][c] = posd;
|
||||
} else {
|
||||
position[1][c] = posd;
|
||||
}
|
||||
if (position[0][d] == posd) {
|
||||
position[0][d] = posx2;
|
||||
} else {
|
||||
position[1][d] = posx2;
|
||||
}
|
||||
}
|
||||
}
|
||||
out.println(answer.size());
|
||||
for (String s : answer) {
|
||||
out.println(s);
|
||||
}
|
||||
}
|
||||
}
|
27
archive/2017.01/2017.01.10 - unsorted/TaskK.task
Normal file
27
archive/2017.01/2017.01.10 - unsorted/TaskK.task
Normal file
@@ -0,0 +1,27 @@
|
||||
5 TaskK
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
13 3
|
||||
1 1 2
|
||||
2 3 3
|
||||
1 0
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.TaskK
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.01.10
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
424
archive/2017.02/2017.02.11 - unsorted/Pizza.java
Normal file
424
archive/2017.02/2017.02.11 - unsorted/Pizza.java
Normal file
@@ -0,0 +1,424 @@
|
||||
package chelper;
|
||||
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.StringWriter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class Pizza {
|
||||
|
||||
class Cut implements Comparable<Cut> {
|
||||
public final int x, y, xs, ys, size;
|
||||
|
||||
public Cut(int x, int y, int xs, int ys) {
|
||||
this.x = x;
|
||||
this.y = y;
|
||||
this.xs = xs;
|
||||
this.ys = ys;
|
||||
size = xs * ys;
|
||||
}
|
||||
|
||||
boolean okay(Solution solution) {
|
||||
if (x + xs > n || y + ys > m) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int size = xs * ys;
|
||||
if (size > maxSize) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int tomatoCount = prefixSum[x + xs - 1][y + ys - 1];
|
||||
if (x > 0) {
|
||||
tomatoCount -= prefixSum[x - 1][y + ys - 1];
|
||||
}
|
||||
if (y > 0) {
|
||||
tomatoCount -= prefixSum[x + xs - 1][y - 1];
|
||||
}
|
||||
if (x > 0 && y > 0) {
|
||||
tomatoCount += prefixSum[x - 1][y - 1];
|
||||
}
|
||||
|
||||
if (tomatoCount < minEach) {
|
||||
return false;
|
||||
}
|
||||
if (size - tomatoCount < minEach) {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int i = 0; i < xs; i++) {
|
||||
for (int j = 0; j < ys; j++) {
|
||||
if (solution.occupied[x + i][y + j]) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Cut{" +
|
||||
"x=" + x +
|
||||
", y=" + y +
|
||||
", xs=" + xs +
|
||||
", ys=" + ys +
|
||||
'}';
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Cut o) {
|
||||
int t = Integer.compare(x, o.x);
|
||||
if (t != 0) {
|
||||
return t;
|
||||
}
|
||||
return Integer.compare(y, o.y);
|
||||
}
|
||||
}
|
||||
|
||||
int randInt(int from, int to) {
|
||||
return from + random.nextInt(to - from);
|
||||
}
|
||||
|
||||
class Solution {
|
||||
final List<Cut> cuts;
|
||||
boolean[][] occupied = new boolean[n][m];
|
||||
boolean[][] starts = new boolean[n][m];
|
||||
LinkedList<Integer> available = new LinkedList<>();
|
||||
int size = 0;
|
||||
|
||||
Solution() {
|
||||
cuts = new ArrayList<>();
|
||||
updateFree();
|
||||
}
|
||||
|
||||
Solution(Solution other) {
|
||||
cuts = new ArrayList<>(other.cuts);
|
||||
size = other.size;
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
occupied[i][j] = other.occupied[i][j];
|
||||
}
|
||||
}
|
||||
updateFree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
List<Cut> sorted = new ArrayList<>(cuts);
|
||||
Collections.sort(sorted);
|
||||
|
||||
StringWriter sw = new StringWriter();
|
||||
OutputWriter out = new OutputWriter(sw);
|
||||
|
||||
out.println(cuts.size());
|
||||
for (Cut cut : sorted) {
|
||||
out.printf("%d %d %d %d\n", cut.x, cut.y, cut.x + cut.xs - 1, cut.y + cut.ys - 1);
|
||||
}
|
||||
sw.flush();
|
||||
|
||||
return sw.toString();
|
||||
}
|
||||
|
||||
void updateFree() {
|
||||
available.clear();
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
if (!occupied[i][j]) {
|
||||
available.add(i * m + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Cut makeRandomCut() {
|
||||
int tries = 0;
|
||||
while (tries < maxTries && !available.isEmpty()) {
|
||||
int x = available.getFirst() / m;
|
||||
int y = available.getFirst() % m;
|
||||
available.removeFirst();
|
||||
|
||||
/*int x = random.nextInt(n);
|
||||
int y = random.nextInt(m);*/
|
||||
|
||||
if (occupied[x][y]) {
|
||||
tries++;
|
||||
continue;
|
||||
}
|
||||
|
||||
/*int xs = random.nextInt(maxSize - 1) + 1;
|
||||
int maxYs = maxSize / xs;
|
||||
int ys = maxYs == 1 ? 1 : (random.nextInt(maxYs - 1) + 1);
|
||||
|
||||
if (Math.random() < 0.5) {
|
||||
int t = xs;
|
||||
xs = ys;
|
||||
ys = t;
|
||||
}*/
|
||||
|
||||
int xs = randInt(1, sizeVariation);
|
||||
int ys = randInt(2 * minEach / xs, maxSize / xs + 1);
|
||||
|
||||
if (Math.random() < 0.5) {
|
||||
int t = xs;
|
||||
xs = ys;
|
||||
ys = t;
|
||||
}
|
||||
|
||||
Cut cut = new Cut(x, y, xs, ys);
|
||||
if (!cut.okay(this)) {
|
||||
tries++;
|
||||
continue;
|
||||
}
|
||||
|
||||
return cut;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
void add(Cut cut) {
|
||||
cuts.add(cut);
|
||||
|
||||
starts[cut.x][cut.y] = true;
|
||||
starts[cut.x][cut.y + cut.ys - 1] = true;
|
||||
starts[cut.x + cut.xs - 1][cut.y] = true;
|
||||
starts[cut.x + cut.xs - 1][cut.y + cut.ys - 1] = true;
|
||||
|
||||
for (int i = 0; i < cut.xs; i++) {
|
||||
for (int j = 0; j < cut.ys; j++) {
|
||||
occupied[cut.x + i][cut.y + j] = true;
|
||||
}
|
||||
}
|
||||
|
||||
size += cut.size;
|
||||
}
|
||||
|
||||
void remove(int removeIndex) {
|
||||
Cut cut = cuts.get(removeIndex);
|
||||
|
||||
cuts.remove(removeIndex);
|
||||
|
||||
for (int i = 0; i < cut.xs; i++) {
|
||||
for (int j = 0; j < cut.ys; j++) {
|
||||
occupied[cut.x + i][cut.y + j] = false;
|
||||
// available.add((cut.x + i) * m + cut.y + j);
|
||||
}
|
||||
}
|
||||
|
||||
size -= cut.size;
|
||||
}
|
||||
|
||||
void greedy() {
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
if (occupied[i][j]) {
|
||||
continue;
|
||||
}
|
||||
for (int ys = maxSize; ys >= 1; ys--) {
|
||||
for (int xs = maxSize / ys + 1; xs >= 1; xs--) {
|
||||
if (xs * ys < minEach * 2) {
|
||||
break;
|
||||
}
|
||||
Cut cut = new Cut(i, j, xs, ys);
|
||||
if (cut.okay(this)) {
|
||||
add(cut);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Solution tryProb() {
|
||||
Solution solution = new Solution();
|
||||
solution.greedy();
|
||||
return solution;
|
||||
}
|
||||
|
||||
int n, m, minEach, maxSize;
|
||||
boolean[][] map;
|
||||
int[][] prefixSum;
|
||||
Random random = new Random();
|
||||
|
||||
int iterations = 1000000;
|
||||
int printEach = 100000;
|
||||
// int updateAvailableEach = 1000;
|
||||
double maxTemp = 1;
|
||||
double scoreModifier = 1e0;
|
||||
int sizeVariation = 8;
|
||||
int maxTries = 10;
|
||||
double dropProbability = 0.5;
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
String name = in.nextString();
|
||||
n = in.nextInt();
|
||||
m = in.nextInt();
|
||||
minEach = in.nextInt();
|
||||
maxSize = in.nextInt();
|
||||
|
||||
// n = 100;
|
||||
// m = 100;
|
||||
|
||||
map = new boolean[n][m];
|
||||
prefixSum = new int[n][m];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
String s = in.nextLine();
|
||||
for (int j = 0; j < m; j++) {
|
||||
map[i][j] = s.charAt(j) == 'T';
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
if (map[i][j]) {
|
||||
prefixSum[i][j]++;
|
||||
}
|
||||
|
||||
if (i > 0) {
|
||||
prefixSum[i][j] += prefixSum[i - 1][j];
|
||||
}
|
||||
if (j > 0) {
|
||||
prefixSum[i][j] += prefixSum[i][j - 1];
|
||||
}
|
||||
if (i > 0 && j > 0) {
|
||||
prefixSum[i][j] -= prefixSum[i - 1][j - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Solution solution = new Solution();
|
||||
int globalMax = 0;
|
||||
Solution bestSolution = null;
|
||||
int skips = 0;
|
||||
|
||||
|
||||
|
||||
/*for (int i = 0; i < iterations; i++) {
|
||||
int newSize;
|
||||
boolean remove;
|
||||
int removeIndex = 0;
|
||||
Cut newCut = null;
|
||||
|
||||
if (!solution.cuts.isEmpty() && Math.random() < dropProbability) {
|
||||
remove = true;
|
||||
removeIndex = random.nextInt(solution.cuts.size());
|
||||
newSize = solution.size - solution.cuts.get(removeIndex).size;
|
||||
} else {
|
||||
newCut = solution.makeRandomCut();
|
||||
if (newCut == null) {
|
||||
i--;
|
||||
skips++;
|
||||
continue;
|
||||
} else {
|
||||
remove = false;
|
||||
newSize = solution.size + newCut.size;
|
||||
}
|
||||
}
|
||||
|
||||
if (solution.available.size() == 0) {
|
||||
solution.updateFree();
|
||||
}
|
||||
|
||||
double temp = maxTemp * (1 - (double)i / iterations);
|
||||
|
||||
double prob = Math.exp(((double)newSize - solution.size) * scoreModifier / temp);
|
||||
|
||||
if (newSize > solution.size || Math.random() < prob) {
|
||||
if (remove) {
|
||||
solution.remove(removeIndex);
|
||||
} else {
|
||||
solution.add(newCut);
|
||||
}
|
||||
}
|
||||
|
||||
if (solution.size > globalMax) {
|
||||
globalMax = solution.size;
|
||||
// bestSolution = new Solution(solution);
|
||||
}
|
||||
if (i % printEach == 0) {
|
||||
System.out.println("---");
|
||||
System.out.printf("Temp %.2f\n", temp);
|
||||
System.out.printf("Count %d\n", solution.cuts.size());
|
||||
System.out.printf("Size %d\n", solution.size);
|
||||
System.out.printf("TSize %d\n", n * m);
|
||||
System.out.printf("%% %.4f\n", (double)solution.size / n / m);
|
||||
System.out.printf("Max %d\n", globalMax);
|
||||
System.out.printf("Avail %d\n", solution.available.size());
|
||||
System.out.printf("Skips %d\n", skips);
|
||||
System.out.printf("Iters %d\n", i);
|
||||
System.out.println("---");
|
||||
}
|
||||
}*/
|
||||
|
||||
|
||||
solution = tryProb();
|
||||
|
||||
if (bestSolution != null) {
|
||||
solution = bestSolution;
|
||||
}
|
||||
System.out.println(solution.size);
|
||||
|
||||
try {
|
||||
FileWriter fileWriter = new FileWriter(name + ".txt");
|
||||
fileWriter.write(solution.toString());
|
||||
fileWriter.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
try {
|
||||
FileWriter fileWriter = new FileWriter("map.txt");
|
||||
OutputWriter out2 = new OutputWriter(fileWriter);
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
if (map[i][j] && solution.occupied[i][j] && solution.starts[i][j]) {
|
||||
out2.print('T');
|
||||
}
|
||||
if (!map[i][j] && solution.occupied[i][j] && solution.starts[i][j]) {
|
||||
out2.print('M');
|
||||
}
|
||||
if (map[i][j] && solution.occupied[i][j] && !solution.starts[i][j]) {
|
||||
out2.print('t');
|
||||
}
|
||||
if (!map[i][j] && solution.occupied[i][j] && !solution.starts[i][j]) {
|
||||
out2.print('m');
|
||||
}
|
||||
if (map[i][j] && !solution.occupied[i][j]) {
|
||||
out2.print(',');
|
||||
}
|
||||
if (!map[i][j] && !solution.occupied[i][j]) {
|
||||
out2.print('.');
|
||||
}
|
||||
}
|
||||
out2.println();
|
||||
}
|
||||
out2.flush();
|
||||
fileWriter.close();
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
Map<String, Integer> stats = new HashMap<>();
|
||||
for (Cut cut : solution.cuts) {
|
||||
String s = cut.xs + "x" + cut.ys;
|
||||
stats.putIfAbsent(s, 0);
|
||||
stats.put(s, stats.get(s) + 1);
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Integer> entry : stats.entrySet()) {
|
||||
System.out.println(entry.getKey() + " " + entry.getValue());
|
||||
}
|
||||
}
|
||||
}
|
1254
archive/2017.02/2017.02.11 - unsorted/Pizza.task
Normal file
1254
archive/2017.02/2017.02.11 - unsorted/Pizza.task
Normal file
File diff suppressed because it is too large
Load Diff
210
archive/2017.02/2017.02.23 - unsorted/Video.java
Normal file
210
archive/2017.02/2017.02.23 - unsorted/Video.java
Normal file
@@ -0,0 +1,210 @@
|
||||
package chelper;
|
||||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class Video {
|
||||
int cacheSize;
|
||||
List<Cache> caches = new ArrayList<>();
|
||||
List<Endpoint> endpoints = new ArrayList<>();
|
||||
List<Integer> itemSizes = new ArrayList<>();
|
||||
List<Request> requests = new ArrayList<>();
|
||||
long totalWeight = 0;
|
||||
|
||||
OutputWriter log;
|
||||
|
||||
static boolean firstRun = true;
|
||||
|
||||
Solution makeSolution(double[] features) {
|
||||
Solution solution = new Solution(caches, cacheSize);
|
||||
|
||||
List<Request> requestsLocal = new ArrayList<>(requests);
|
||||
|
||||
Collections.sort(requestsLocal, new Comparator<Request>() {
|
||||
@Override
|
||||
public int compare(Request o1, Request o2) {
|
||||
double w1 = 1.0
|
||||
* Math.pow(o1.weight, features[0])
|
||||
* Math.pow(o1.endpoint.serverDelay, features[1])
|
||||
* Math.pow(itemSizes.get(o1.itemId), features[2]);
|
||||
double w2 = 1.0
|
||||
* Math.pow(o2.weight, features[0])
|
||||
* Math.pow(o2.endpoint.serverDelay, features[1])
|
||||
* Math.pow(itemSizes.get(o2.itemId), features[2]);
|
||||
|
||||
return Double.compare(w1, w2);
|
||||
}
|
||||
});
|
||||
Collections.reverse(requestsLocal);
|
||||
|
||||
|
||||
for (Request request : requestsLocal) {
|
||||
Endpoint endpoint = request.endpoint;
|
||||
int itemId = request.itemId;
|
||||
int weight = request.weight;
|
||||
int itemSize = itemSizes.get(itemId);
|
||||
|
||||
for (Cache cache : endpoint.cacheDelaysSorted) {
|
||||
if (solution.cacheSets.get(cache).contains(itemId)) {
|
||||
break;
|
||||
}
|
||||
|
||||
int sizeLeft = solution.sizeLeft.get(cache);
|
||||
|
||||
if (sizeLeft >= itemSize) {
|
||||
solution.cacheSets.get(cache).add(itemId);
|
||||
solution.sizeLeft.put(cache, sizeLeft - itemSize);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return solution;
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
String testName = in.nextLine();
|
||||
try {
|
||||
log = new OutputWriter(new FileWriter("log", true));
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
if (firstRun) {
|
||||
log.println("========================================================================");
|
||||
}
|
||||
firstRun = false;
|
||||
log.println("-----");
|
||||
|
||||
log.println(testName);
|
||||
|
||||
int itemCounts = in.nextInt();
|
||||
int endpointCount = in.nextInt();
|
||||
int requestCount = in.nextInt();
|
||||
int cacheCount = in.nextInt();
|
||||
cacheSize = in.nextInt();
|
||||
|
||||
for (int i = 0; i < itemCounts; i++) {
|
||||
itemSizes.add(in.nextInt());
|
||||
}
|
||||
|
||||
for (int i = 0; i < cacheCount; i++) {
|
||||
caches.add(new Cache(i));
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < endpointCount; i++) {
|
||||
Endpoint endpoint = new Endpoint(i, in.nextInt());
|
||||
|
||||
int connectionCount = in.nextInt();
|
||||
for (int j = 0; j < connectionCount; j++) {
|
||||
int serverId = in.nextInt();
|
||||
int delay = in.nextInt();
|
||||
|
||||
Cache cache = caches.get(serverId);
|
||||
|
||||
cache.endpointDelays.put(endpoint, delay);
|
||||
endpoint.cacheDelays.put(cache, delay);
|
||||
}
|
||||
|
||||
endpoints.add(endpoint);
|
||||
}
|
||||
|
||||
for (Endpoint endpoint : endpoints) {
|
||||
endpoint.sortCacheDelays();
|
||||
}
|
||||
|
||||
for (int i = 0; i < requestCount; i++) {
|
||||
int itemId = in.nextInt();
|
||||
int endpointId = in.nextInt();
|
||||
int requestWeight = in.nextInt();
|
||||
|
||||
totalWeight += requestWeight;
|
||||
|
||||
Endpoint endpoint = endpoints.get(endpointId);
|
||||
endpoint.itemRequests.put(itemId, requestWeight);
|
||||
requests.add(new Request(itemId, endpoint, requestWeight));
|
||||
}
|
||||
|
||||
double bestScore = -1;
|
||||
Solution bestSolution = null;
|
||||
String bestDesc = "";
|
||||
|
||||
double[] features = new double[]{1, 1.5, -0.5};
|
||||
Solution solution = makeSolution(features);
|
||||
double score = solution.getScore(requests, totalWeight);
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
double temp = 1;
|
||||
for (int i = 0; i < 1000; i++) {
|
||||
double T = temp * (1 - (double)i / 100);
|
||||
|
||||
double[] newFeatures = new double[features.length];
|
||||
for (int j = 0; j < features.length; j++) {
|
||||
newFeatures[j] = features[j];
|
||||
}
|
||||
|
||||
int index = random.nextInt(features.length);
|
||||
int sign = 1;
|
||||
if (Math.random() < 0.5) {
|
||||
sign = -1;
|
||||
}
|
||||
newFeatures[index] += sign * Math.random() * T;
|
||||
|
||||
Solution newSolution = makeSolution(newFeatures);
|
||||
double newScore = newSolution.getScore(requests, totalWeight);
|
||||
System.out.println(i);
|
||||
System.out.println(Arrays.toString(features));
|
||||
System.out.println(newScore);
|
||||
System.out.flush();
|
||||
|
||||
if (newScore > bestScore) {
|
||||
bestScore = newScore;
|
||||
bestSolution = newSolution;
|
||||
}
|
||||
|
||||
double prob = Math.exp((newScore - score) / temp);
|
||||
|
||||
if (newScore > score || Math.random() < prob) {
|
||||
solution = newSolution;
|
||||
features = newFeatures;
|
||||
score = newScore;
|
||||
}
|
||||
}
|
||||
|
||||
log.println("Score: " + bestScore);
|
||||
log.println("Desc: " + Arrays.toString(features));
|
||||
log.println("TotalWeight: " + totalWeight);
|
||||
|
||||
try {
|
||||
out = new OutputWriter("hashcode/" + testName + ".out");
|
||||
} catch (FileNotFoundException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
out.println(caches.size());
|
||||
for (Cache cache : caches) {
|
||||
out.print(cache.id + " ");
|
||||
for (Integer itemId : bestSolution.cacheSets.get(cache)) {
|
||||
out.print(itemId + " ");
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
|
||||
out.flush();
|
||||
|
||||
log.flush();
|
||||
}
|
||||
}
|
763808
archive/2017.02/2017.02.23 - unsorted/Video.task
Normal file
763808
archive/2017.02/2017.02.23 - unsorted/Video.task
Normal file
File diff suppressed because one or more lines are too long
64
archive/2017.03/2017.03.04 - unsorted/B.java
Normal file
64
archive/2017.03/2017.03.04 - unsorted/B.java
Normal file
@@ -0,0 +1,64 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class B {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int pol = in.nextInt();
|
||||
if (pol == 0) {
|
||||
out.print(-1);
|
||||
return;
|
||||
}
|
||||
|
||||
List<Chelik> cheliki = new ArrayList<>();
|
||||
for (int i = 2; i <= n; i++) {
|
||||
cheliki.add(new Chelik(i, in.nextInt()));
|
||||
}
|
||||
Collections.sort(cheliki);
|
||||
cheliki.add(0, new Chelik(1, pol));
|
||||
|
||||
List<String> answer = new ArrayList<>();
|
||||
|
||||
int left = 0;
|
||||
for (int right = 1; right < n; right++) {
|
||||
if (left == right) {
|
||||
out.print(-1);
|
||||
return;
|
||||
}
|
||||
if (cheliki.get(left).dzun > 0) {
|
||||
answer.add(cheliki.get(left).index + " " + cheliki.get(right).index);
|
||||
cheliki.get(left).dzun--;
|
||||
} else {
|
||||
left++;
|
||||
right--;
|
||||
}
|
||||
}
|
||||
|
||||
out.println(answer.size());
|
||||
for (String s : answer) {
|
||||
out.println(s);
|
||||
}
|
||||
}
|
||||
|
||||
class Chelik implements Comparable<Chelik> {
|
||||
int index;
|
||||
int dzun;
|
||||
|
||||
public Chelik(int index, int dzun) {
|
||||
this.index = index;
|
||||
this.dzun = dzun;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Chelik o) {
|
||||
return Integer.compare(o.dzun, dzun);
|
||||
}
|
||||
}
|
||||
}
|
37
archive/2017.03/2017.03.04 - unsorted/B.task
Normal file
37
archive/2017.03/2017.03.04 - unsorted/B.task
Normal file
@@ -0,0 +1,37 @@
|
||||
1 B
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
3
|
||||
0
|
||||
10
|
||||
4
|
||||
1 2 1 0
|
||||
-1
|
||||
1
|
||||
1
|
||||
13 6
|
||||
2 0 1 3 2 0
|
||||
-1
|
||||
1
|
||||
2
|
||||
7 3
|
||||
0 2 2
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.B
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.04
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
121
archive/2017.03/2017.03.04 - unsorted/C.java
Normal file
121
archive/2017.03/2017.03.04 - unsorted/C.java
Normal file
@@ -0,0 +1,121 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class C {
|
||||
char[] dirsOrderLabels = {'D', 'L', 'R', 'U'};
|
||||
int[][] dirsOrder = {
|
||||
{1, 0}, //D
|
||||
{0, -1}, //L
|
||||
{0, 1}, //R
|
||||
{-1, 0}, //U
|
||||
};
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int m = in.nextInt();
|
||||
int k = in.nextInt();
|
||||
|
||||
int startX = -1;
|
||||
int startY = -1;
|
||||
|
||||
boolean[][] map = new boolean[n][m];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
String s = in.nextLine();
|
||||
for (int j = 0; j < m; j++) {
|
||||
map[i][j] = s.charAt(j) != '*';
|
||||
if (s.charAt(j) == 'X') {
|
||||
startX = i;
|
||||
startY = j;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int[][] distances = new int[n][m];
|
||||
for (int i = 0; i < n; i++) {
|
||||
Arrays.fill(distances[i], Integer.MAX_VALUE);
|
||||
}
|
||||
|
||||
Queue<int[]> queue = new LinkedList<>();
|
||||
queue.add(new int[]{startX, startY});
|
||||
distances[startX][startY] = 0;
|
||||
|
||||
while (!queue.isEmpty()) {
|
||||
int[] posAr = queue.poll();
|
||||
int x = posAr[0];
|
||||
int y = posAr[1];
|
||||
|
||||
for (int[] dir : dirsOrder) {
|
||||
int xx = x + dir[0];
|
||||
int yy = y + dir[1];
|
||||
|
||||
if (xx < 0 || xx >= n || yy < 0 || yy >= m) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!map[xx][yy]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (distances[xx][yy] <= distances[x][y] + 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
distances[xx][yy] = distances[x][y] + 1;
|
||||
queue.add(new int[]{xx, yy});
|
||||
}
|
||||
}
|
||||
|
||||
StringBuilder answer = new StringBuilder();
|
||||
|
||||
int x = startX;
|
||||
int y = startY;
|
||||
int timeLeft = k;
|
||||
|
||||
while (timeLeft >= distances[x][y] && timeLeft > 0) {
|
||||
boolean ok = false;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int[] dir = dirsOrder[i];
|
||||
int xx = x + dir[0];
|
||||
int yy = y + dir[1];
|
||||
|
||||
if (xx < 0 || xx >= n || yy < 0 || yy >= m) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!map[xx][yy]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (timeLeft == distances[x][y] && distances[xx][yy] >= distances[x][y]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
ok = true;
|
||||
x = xx;
|
||||
y = yy;
|
||||
timeLeft--;
|
||||
answer.append(dirsOrderLabels[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
if (!ok) {
|
||||
out.println("IMPOSSIBLE");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (timeLeft != 0 || x != startX || y != startY) {
|
||||
out.println("IMPOSSIBLE");
|
||||
return;
|
||||
}
|
||||
|
||||
out.println(answer);
|
||||
}
|
||||
}
|
81
archive/2017.03/2017.03.04 - unsorted/C.task
Normal file
81
archive/2017.03/2017.03.04 - unsorted/C.task
Normal file
@@ -0,0 +1,81 @@
|
||||
1 C
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
9
|
||||
0
|
||||
13 2 3 2
|
||||
.**
|
||||
X..
|
||||
2 RL
|
||||
1
|
||||
1
|
||||
41 5 6 14
|
||||
..***.
|
||||
*...X.
|
||||
..*...
|
||||
..*.**
|
||||
....*.
|
||||
14 DLDDLLLRRRUURU
|
||||
1
|
||||
2
|
||||
17 3 3 4
|
||||
***
|
||||
*X*
|
||||
***
|
||||
11 IMPOSSIBLE
|
||||
|
||||
1
|
||||
3
|
||||
13 2 3 4
|
||||
.**
|
||||
X..
|
||||
-1
|
||||
1
|
||||
4
|
||||
29 4 5 5
|
||||
*****
|
||||
*X***
|
||||
*.***
|
||||
*.***
|
||||
-1
|
||||
1
|
||||
5
|
||||
11 2 2 1
|
||||
.X
|
||||
..
|
||||
10 IMPOSSIBLE
|
||||
1
|
||||
6
|
||||
11 2 2 4
|
||||
.X
|
||||
..
|
||||
4 DLRU
|
||||
1
|
||||
7
|
||||
7 1 1 2
|
||||
X
|
||||
10 IMPOSSIBLE
|
||||
1
|
||||
8
|
||||
9 2 1 2
|
||||
X
|
||||
.
|
||||
2 DU
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.C
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.04
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
45
archive/2017.03/2017.03.05 - unsorted/D.java
Normal file
45
archive/2017.03/2017.03.05 - unsorted/D.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class D {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
int k = in.nextInt();
|
||||
int M = 1 << 16;
|
||||
int[] a = new int[M];
|
||||
for (int i = 0; i < n; i++) {
|
||||
int x = in.nextInt();
|
||||
a[x]++;
|
||||
}
|
||||
|
||||
List<Integer> masks = new ArrayList<>();
|
||||
for (int i = 0; i < M; i++) {
|
||||
if (Integer.bitCount(i) == k) {
|
||||
masks.add(i);
|
||||
}
|
||||
}
|
||||
|
||||
long answer = 0;
|
||||
for (int i = 0; i < M; i++) {
|
||||
if (a[i] == 0) {
|
||||
continue;
|
||||
}
|
||||
for (int mask : masks) {
|
||||
if ((i ^ mask) < i) {
|
||||
answer += a[i] * a[i ^ mask];
|
||||
}
|
||||
if ((i ^ mask) == i) {
|
||||
answer += a[i] * (a[i] - 1) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
out.println(answer);
|
||||
}
|
||||
|
||||
}
|
31
archive/2017.03/2017.03.05 - unsorted/D.task
Normal file
31
archive/2017.03/2017.03.05 - unsorted/D.task
Normal file
@@ -0,0 +1,31 @@
|
||||
1 D
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
2
|
||||
0
|
||||
11 4 1
|
||||
0 3 2 1
|
||||
1 4
|
||||
1
|
||||
1
|
||||
27 6 0
|
||||
200 100 100 100 200 200
|
||||
1 6
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.D
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.05
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
62
archive/2017.03/2017.03.11 - unsorted/D.java
Normal file
62
archive/2017.03/2017.03.11 - unsorted/D.java
Normal file
@@ -0,0 +1,62 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class D {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
char[] seq = in.nextLine().toCharArray();
|
||||
|
||||
int x[] = new int[n];
|
||||
int y[] = new int[n];
|
||||
int currentDepth = 0;
|
||||
int maxDepth = 0;
|
||||
|
||||
int w = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (seq[i] == '[') {
|
||||
currentDepth++;
|
||||
w++;
|
||||
}
|
||||
maxDepth = Math.max(maxDepth, currentDepth);
|
||||
y[i] = currentDepth;
|
||||
if (seq[i] == ']') {
|
||||
currentDepth--;
|
||||
w++;
|
||||
if (seq[i - 1] == '[') {
|
||||
w += 3;
|
||||
}
|
||||
}
|
||||
x[i] = w - 1;
|
||||
}
|
||||
|
||||
int h = maxDepth * 2 + 1;
|
||||
|
||||
char[][] answer = new char[h][w];
|
||||
|
||||
for (int i = 0; i < h; i++) {
|
||||
Arrays.fill(answer[i], ' ');
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j <= maxDepth - y[i]; j++) {
|
||||
answer[h / 2 - j][x[i]] = '|';
|
||||
answer[h / 2 + j][x[i]] = '|';
|
||||
}
|
||||
answer[h / 2 - (maxDepth - y[i] + 1)][x[i]] = '+';
|
||||
answer[h / 2 + (maxDepth - y[i] + 1)][x[i]] = '+';
|
||||
|
||||
int dx = seq[i] == '[' ? 1 : -1;
|
||||
|
||||
answer[h / 2 - (maxDepth - y[i] + 1)][x[i] + dx] = '-';
|
||||
answer[h / 2 + (maxDepth - y[i] + 1)][x[i] + dx] = '-';
|
||||
}
|
||||
|
||||
for (int i = 0; i < h; i++) {
|
||||
out.println(new String(answer[i]));
|
||||
}
|
||||
}
|
||||
}
|
74
archive/2017.03/2017.03.11 - unsorted/D.task
Normal file
74
archive/2017.03/2017.03.11 - unsorted/D.task
Normal file
@@ -0,0 +1,74 @@
|
||||
1 D
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
7
|
||||
0
|
||||
10 8
|
||||
[[][]][]
|
||||
89 +- -++- -+
|
||||
|+- -++- -+|| |
|
||||
|| || ||| |
|
||||
|+- -++- -+|| |
|
||||
+- -++- -+
|
||||
1
|
||||
1
|
||||
8 6
|
||||
[[[]]]
|
||||
69 +- -+
|
||||
|+- -+|
|
||||
||+- -+||
|
||||
||| |||
|
||||
||+- -+||
|
||||
|+- -+|
|
||||
+- -+
|
||||
1
|
||||
2
|
||||
8 6
|
||||
[[][]]
|
||||
64 +- -+
|
||||
|+- -++- -+|
|
||||
|| || ||
|
||||
|+- -++- -+|
|
||||
+- -+
|
||||
1
|
||||
3
|
||||
4 2
|
||||
[]
|
||||
17 +- -+
|
||||
| |
|
||||
+- -+
|
||||
1
|
||||
4
|
||||
6 4
|
||||
[][]
|
||||
32 +- -++- -+
|
||||
| || |
|
||||
+- -++- -+
|
||||
1
|
||||
5
|
||||
19 16
|
||||
[[[[[][]][]][]]]
|
||||
-1
|
||||
1
|
||||
6
|
||||
104 100
|
||||
[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[[]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]]
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
9 chelper.D
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.11
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,58 @@
|
||||
33 A - Bear and Friendship Condition
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
4
|
||||
0
|
||||
16 4 3
|
||||
1 3
|
||||
3 4
|
||||
1 4
|
||||
|
||||
4 YES
|
||||
|
||||
1
|
||||
1
|
||||
20 4 4
|
||||
3 1
|
||||
2 3
|
||||
3 4
|
||||
1 2
|
||||
|
||||
3 NO
|
||||
|
||||
1
|
||||
2
|
||||
22 10 4
|
||||
4 3
|
||||
5 10
|
||||
8 9
|
||||
1 2
|
||||
|
||||
4 YES
|
||||
|
||||
1
|
||||
3
|
||||
12 3 2
|
||||
1 2
|
||||
2 3
|
||||
|
||||
3 NO
|
||||
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskA
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.18
|
||||
21 VK Cup 2017 - Round 1
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,39 @@
|
||||
28 B - Bear and Different Names
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
3
|
||||
0
|
||||
25 8 3
|
||||
NO NO YES YES YES NO
|
||||
|
||||
42 Adam Bob Bob Cpqepqwer Limak Adam Bob Adam
|
||||
1
|
||||
1
|
||||
11 9 8
|
||||
YES NO
|
||||
|
||||
45 R Q Ccccccccc Ccocc Ccc So Strong Samples Ccc
|
||||
1
|
||||
2
|
||||
10 3 2
|
||||
NO NO
|
||||
|
||||
8 Na Na Na
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskB
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.18
|
||||
21 VK Cup 2017 - Round 1
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,58 @@
|
||||
23 C - Bear and Tree Jumps
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
3
|
||||
0
|
||||
24 6 2
|
||||
1 2
|
||||
1 3
|
||||
2 4
|
||||
2 5
|
||||
4 6
|
||||
|
||||
3 20
|
||||
|
||||
1
|
||||
1
|
||||
58 13 3
|
||||
1 2
|
||||
3 2
|
||||
4 2
|
||||
5 2
|
||||
3 6
|
||||
10 6
|
||||
6 7
|
||||
6 13
|
||||
5 8
|
||||
5 9
|
||||
9 11
|
||||
11 12
|
||||
|
||||
4 114
|
||||
|
||||
1
|
||||
2
|
||||
12 3 5
|
||||
2 1
|
||||
3 1
|
||||
|
||||
2 3
|
||||
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskC
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.18
|
||||
21 VK Cup 2017 - Round 1
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,56 @@
|
||||
20 D - Bear and Company
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
5
|
||||
0
|
||||
7 4
|
||||
VKVK
|
||||
|
||||
2 3
|
||||
|
||||
1
|
||||
1
|
||||
8 5
|
||||
BVVKV
|
||||
|
||||
2 2
|
||||
|
||||
1
|
||||
2
|
||||
10 7
|
||||
VVKEVKK
|
||||
|
||||
2 3
|
||||
|
||||
1
|
||||
3
|
||||
24 20
|
||||
VKVKVVVKVOVKVQKKKVVK
|
||||
|
||||
2 8
|
||||
|
||||
1
|
||||
4
|
||||
8 5
|
||||
LIMAK
|
||||
|
||||
2 0
|
||||
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskD
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.18
|
||||
21 VK Cup 2017 - Round 1
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,45 @@
|
||||
29 E - Bear and Rectangle Strips
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
3
|
||||
0
|
||||
42 6
|
||||
70 70 70 70 70 -15
|
||||
90 -60 -30 30 -30 15
|
||||
|
||||
2 3
|
||||
|
||||
1
|
||||
1
|
||||
19 4
|
||||
0 -1 0 0
|
||||
0 0 1 0
|
||||
|
||||
2 6
|
||||
|
||||
1
|
||||
2
|
||||
68 3
|
||||
1000000000 999999999 -1000000000
|
||||
999999999 -1000000000 -999999998
|
||||
|
||||
2 1
|
||||
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskE
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.18
|
||||
21 VK Cup 2017 - Round 1
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,49 @@
|
||||
30 F - Bear and Isomorphic Points
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
1
|
||||
0
|
||||
109 4
|
||||
4
|
||||
5 3
|
||||
0 1
|
||||
10 1
|
||||
3 51
|
||||
3
|
||||
-999123 700000
|
||||
-950000 123456
|
||||
-950000 987654
|
||||
3
|
||||
2 3
|
||||
10 -1
|
||||
-4 6
|
||||
5
|
||||
1 3
|
||||
5 2
|
||||
6 1
|
||||
4 4
|
||||
-3 3
|
||||
|
||||
73 250.000000000000
|
||||
100000000000.000000000000
|
||||
0.000000000000
|
||||
6.562500000000
|
||||
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskF
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.03.18
|
||||
21 VK Cup 2017 - Round 1
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,9 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskA {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskB {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
}
|
||||
}
|
128
archive/2017.03/2017.03.18 - VK Cup 2017 - Round 1/TaskC.java
Normal file
128
archive/2017.03/2017.03.18 - VK Cup 2017 - Round 1/TaskC.java
Normal file
@@ -0,0 +1,128 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskC {
|
||||
int n, k;
|
||||
List<List<Integer>> edges;
|
||||
|
||||
long ans = 0;
|
||||
|
||||
long[] rotCount(long[] x) {
|
||||
long[] res = new long[k];
|
||||
for (int i = 0; i < k; i++) {
|
||||
res[i] = x[(i - 1 + k) % k];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
long[] rotAcc(long[] x) {
|
||||
long[] res = new long[k];
|
||||
for (int i = 0; i < k; i++) {
|
||||
res[i] = x[(i - 1 + k) % k];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
long[] copy(long[] x) {
|
||||
return Arrays.copyOf(x, k);
|
||||
}
|
||||
|
||||
void add(long[] a, long[] b) {
|
||||
for (int i = 0; i < k; i++) {
|
||||
a[i] += b[i];
|
||||
}
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
n = in.nextInt();
|
||||
k = in.nextInt();
|
||||
|
||||
visited = new boolean[n];
|
||||
|
||||
edges = new ArrayList<>();
|
||||
for (int i = 0; i < n; i++) {
|
||||
edges.add(new ArrayList<>());
|
||||
}
|
||||
|
||||
for (int i = 0; i < n - 1; i++) {
|
||||
int a = in.nextInt() - 1;
|
||||
int b = in.nextInt() - 1;
|
||||
|
||||
edges.get(a).add(b);
|
||||
edges.get(b).add(a);
|
||||
}
|
||||
|
||||
// long[] count = new long[k];
|
||||
long[] acc = new long[k];
|
||||
|
||||
Result ans = dfs(0, 0, acc);
|
||||
|
||||
out.println(ans.cost / 2);
|
||||
}
|
||||
|
||||
class Result {
|
||||
long cost;
|
||||
long[] acc;
|
||||
|
||||
public Result(long cost, long[] acc) {
|
||||
this.cost = cost;
|
||||
this.acc = acc;
|
||||
}
|
||||
}
|
||||
|
||||
boolean[] visited;
|
||||
|
||||
// void addComp(long[] a, long[] b) {
|
||||
// for (int i = 0; i < k; i++) {
|
||||
// for (int j = 0; j < k; j++) {
|
||||
// if (i == j) {
|
||||
// continue;
|
||||
// }
|
||||
// long t = a[i] + b[j];
|
||||
// if (i + j >= k) {
|
||||
// ans += ;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
Result dfs(int v, long parentCost, long[] accParent) {
|
||||
visited[v] = true;
|
||||
|
||||
long costParentChildren = parentCost;
|
||||
long costChildren = 0;
|
||||
|
||||
long[] accParentChildren = new long[k];
|
||||
costParentChildren += rot(accParentChildren, accParent);
|
||||
accParentChildren[0] += 1;
|
||||
|
||||
long[] accChildren = new long[k];
|
||||
accChildren[0] += 1;
|
||||
|
||||
for (Integer child : edges.get(v)) {
|
||||
if (visited[child]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Result atChild = dfs(child, costParentChildren, accParentChildren);
|
||||
|
||||
long[] childAcc = new long[k];
|
||||
|
||||
costChildren += atChild.cost;
|
||||
costChildren += rot(childAcc, atChild.acc);
|
||||
costParentChildren += atChild.cost;
|
||||
costParentChildren += rot(childAcc, atChild.acc);
|
||||
|
||||
add(accParentChildren, childAcc);
|
||||
add(accChildren, childAcc);
|
||||
}
|
||||
|
||||
return new Result(costChildren, accChildren);
|
||||
}
|
||||
}
|
@@ -0,0 +1,43 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskD {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
char[] a = in.nextString().toCharArray();
|
||||
|
||||
char c1 = 'V';
|
||||
char c2 = 'K';
|
||||
|
||||
int[][] dp = new int[n][3];
|
||||
for (int i = 0; i < n; i++) {
|
||||
Arrays.fill(dp[i], 100000);
|
||||
}
|
||||
|
||||
if (a[0] == c1) {
|
||||
dp[0][0] = 0;
|
||||
} else if (a[0] == c2) {
|
||||
dp[0][1] = 0;
|
||||
} else {
|
||||
dp[0][2] = 0;
|
||||
}
|
||||
|
||||
for (int i = 1; i < n; i++) {
|
||||
if (a[i] == c1) {
|
||||
dp[i][2] = Math.min(dp[i][2], dp[i - 1][0]);
|
||||
dp[i][2] = Math.min(dp[i][2], dp[i - 1][1]);
|
||||
dp[i][2] = Math.min(dp[i][2], dp[i - 1][2]);
|
||||
} else if (a[i] == c2) {
|
||||
|
||||
} else {
|
||||
dp[i][2] = Math.min(dp[i][2], dp[i - 1][0]);
|
||||
dp[i][2] = Math.min(dp[i][2], dp[i - 1][1]);
|
||||
dp[i][2] = Math.min(dp[i][2], dp[i - 1][2]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskE {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,9 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskF {
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
23 I - Composing Of String
|
||||
6 SINGLE
|
||||
8 STANDARD
|
||||
-1
|
||||
8 STANDARD
|
||||
-1
|
||||
4
|
||||
0
|
||||
13 3
|
||||
a
|
||||
aa
|
||||
a
|
||||
aaa
|
||||
|
||||
2 2
|
||||
|
||||
1
|
||||
1
|
||||
21 4
|
||||
ab
|
||||
aab
|
||||
aa
|
||||
bb
|
||||
baaab
|
||||
|
||||
2 3
|
||||
|
||||
1
|
||||
2
|
||||
18 2
|
||||
aaa
|
||||
bbb
|
||||
aaacbbb
|
||||
|
||||
3 -1
|
||||
|
||||
1
|
||||
3
|
||||
10 2
|
||||
ax
|
||||
xb
|
||||
ab
|
||||
1 2
|
||||
1
|
||||
11 src/chelper
|
||||
8 -Xmx256M
|
||||
4 Main
|
||||
13 chelper.TaskI
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.04.05
|
||||
31 VK Cup 2017 - Wild Card Round 1
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
@@ -0,0 +1,61 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskI {
|
||||
|
||||
public static final int MAGIC_KEK = 1000000;
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
int n = in.nextInt();
|
||||
String[] strings = new String[n];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
strings[i] = in.nextString();
|
||||
}
|
||||
|
||||
String e = in.nextString();
|
||||
|
||||
int m = e.length();
|
||||
|
||||
int[] dp = new int[m + 1];
|
||||
|
||||
Arrays.fill(dp, MAGIC_KEK);
|
||||
|
||||
dp[0] = 0;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < strings[i].length(); j++) {
|
||||
int c = 0;
|
||||
for (int k = 0; j + k < strings[i].length() && c < e.length(); k++) {
|
||||
if (strings[i].charAt(j + k) == e.charAt(c)) {
|
||||
c++;
|
||||
dp[c] = Math.max(dp[c], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < m; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
int c = 0;
|
||||
for (int k = 0; i + c < e.length() && k < strings[j].length(); k++) {
|
||||
if (strings[j].charAt(k) == e.charAt(i + c)) {
|
||||
c++;
|
||||
dp[i + c] = Math.min(dp[i + c], dp[i] + 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (dp[m] >= MAGIC_KEK) {
|
||||
out.println(-1);
|
||||
} else {
|
||||
|
||||
out.println(dp[m]);
|
||||
}
|
||||
}
|
||||
}
|
49
archive/2017.04/2017.04.08 - unsorted/TaskA.java
Normal file
49
archive/2017.04/2017.04.08 - unsorted/TaskA.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.GCJSolution;
|
||||
|
||||
public class TaskA extends GCJSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
char[] s = in.nextString().toCharArray();
|
||||
int k = in.nextInt();
|
||||
|
||||
int n = s.length;
|
||||
|
||||
boolean[] a = new boolean[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i] = s[i] == '+';
|
||||
}
|
||||
|
||||
int ans = 0;
|
||||
|
||||
for (int i = 0; i + k - 1 < n; i++) {
|
||||
if (!a[i]) {
|
||||
for (int j = 0; j < k; j++) {
|
||||
a[i + j] ^= true;
|
||||
}
|
||||
ans++;
|
||||
}
|
||||
}
|
||||
|
||||
boolean ok = true;
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
ok &= a[i];
|
||||
}
|
||||
|
||||
if (ok) {
|
||||
out.println(ans);
|
||||
} else {
|
||||
out.println("IMPOSSIBLE");
|
||||
}
|
||||
|
||||
}
|
||||
}
|
240
archive/2017.04/2017.04.08 - unsorted/TaskA.task
Normal file
240
archive/2017.04/2017.04.08 - unsorted/TaskA.task
Normal file
@@ -0,0 +1,240 @@
|
||||
5 TaskA
|
||||
12 MULTI_NUMBER
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
3
|
||||
0
|
||||
28 3
|
||||
---+-++- 3
|
||||
+++++ 4
|
||||
-+-+- 4
|
||||
41 Case #1: 3
|
||||
Case #2: 0
|
||||
Case #3: IMPOSSIBLE
|
||||
1
|
||||
1
|
||||
897 100
|
||||
---+-++- 3
|
||||
+++++ 4
|
||||
-+-+- 4
|
||||
---- 2
|
||||
-++----+-- 7
|
||||
--+ 2
|
||||
+-+-+-+-+- 2
|
||||
+--- 2
|
||||
++ 2
|
||||
++-+ 2
|
||||
-++- 2
|
||||
+-+-+-+-+- 3
|
||||
-+++ 3
|
||||
---+ 3
|
||||
-+++++++++ 2
|
||||
+--+ 2
|
||||
---------- 10
|
||||
-++++++- 7
|
||||
--++- 2
|
||||
--------- 3
|
||||
-+-+ 2
|
||||
---- 3
|
||||
---+ 2
|
||||
-------++ 7
|
||||
+-- 2
|
||||
--++ 3
|
||||
-+++++++-+ 2
|
||||
++++++++++ 10
|
||||
+- 2
|
||||
-+-+++-+- 6
|
||||
-+++ 2
|
||||
--+- 2
|
||||
-+- 2
|
||||
+++----+ 3
|
||||
-+--++-- 3
|
||||
-+--+-+--+ 2
|
||||
------- 7
|
||||
-++++++++- 10
|
||||
-++- 3
|
||||
+----+ 4
|
||||
-+-- 2
|
||||
+--+-++-++ 4
|
||||
+-- 3
|
||||
+-++ 3
|
||||
+-+- 3
|
||||
++++++ 5
|
||||
+++--+++ 2
|
||||
+-+- 2
|
||||
--+- 3
|
||||
++- 2
|
||||
-+------- 9
|
||||
++-+ 3
|
||||
+-+-+-+- 3
|
||||
---------- 3
|
||||
-+++++++-- 2
|
||||
-- 2
|
||||
-++++++++- 9
|
||||
+-+-++-+ 5
|
||||
+--+ 3
|
||||
---------- 5
|
||||
++-- 2
|
||||
+-+ 3
|
||||
-+- 3
|
||||
-+ 2
|
||||
--- 2
|
||||
+++ 3
|
||||
+-++ 2
|
||||
+++++ 5
|
||||
----++-+ 4
|
||||
+--- 3
|
||||
-+-- 3
|
||||
++++ 2
|
||||
---------- 2
|
||||
+-+-- 3
|
||||
+-----+ 5
|
||||
--++ 2
|
||||
+-+-+-+ 3
|
||||
++++++-+++ 10
|
||||
--+ 3
|
||||
+++- 3
|
||||
++- 3
|
||||
--- 3
|
||||
++++ 3
|
||||
-++ 3
|
||||
++-- 3
|
||||
-+-+-+-+-+ 2
|
||||
----- 4
|
||||
-++ 2
|
||||
+-+ 2
|
||||
-+-+++- 6
|
||||
-++++++++- 8
|
||||
+---+++--- 6
|
||||
+++ 2
|
||||
-++++++++- 2
|
||||
---++++++ 4
|
||||
+++- 2
|
||||
-+-+ 3
|
||||
-+-+--+ 2
|
||||
+-+-+-+-+ 3
|
||||
---------+ 9
|
||||
|
||||
-1
|
||||
1
|
||||
2
|
||||
49828 100
|
||||
---+-++- 3
|
||||
+++++ 4
|
||||
-+-+- 4
|
||||
++++-+---++++-+-++-+-++---++++-+-+-++++---++-+--++++++-++-+-++++-++++-++--++-+--+-+-+-+++-+-----+-+---+-+---+-+-++---+--+-+----+--+++--+++--+--++-++---++-++++++-+------+---+-++++-+-++++----+--+---+++++-+-+--+++--------+++--++--+---++++---++-++++++-++-+--+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-+---++++-+-++-+-++---++++-+-+-++++---++-+--++++++-++-+-++++-++++-++--++-+--+-+-+-+++-+-----+-+---+-+---+-+-++---+--+-+----+--+++--+++--+--++-++---++-++++++-+------+---+-++++-+-++++----+--+---+++++-+-+--+++--------+++--++--+---++++---++-++++++-++-+--++ 437
|
||||
+-++++++--+--++-+-+++--+-++++-+--++-+++++----+--+-++++++------+--+-+-++----+++---+-+-------+-++-+--+-++---++-------++-----++++---+---+-++-+++--+-+++---++---+--+++++------+-++++-+++++--+--+-+-++-+-++++++-+--+------------++-+--+--++-++-+-+--++++---++++-++-+----++-+-++--++-+-+--++-----++++--+-++---+-+-+++++-++-+++-+-+-++-+---+++++--++----+++- 17
|
||||
-+++--++-+-+-+++----+--++----++--++-++--+----+--++++-+-+-+++----+++-+-+---+++++++-+--++--++-+++-+-++-++--+++--++++++-+++++---+---+-++-+-+++++++++++---+--++-+--++--+--+++++---+-++++--++---+-+++---+- 41
|
||||
---+---+--+++-+++++-++-+--++-++--+++-----++++++++---+--+++--+++-++++++++++++++++++++++++++++++++++++-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---+---+--+++-+++++-++-+--++-++--+++-----++++++++---+--+++--+++-+ 665
|
||||
++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++- 2
|
||||
++++++++---+-+-+++--++++--+-+---++++-------+-+-+-+--+++---+++--+--+---+++-+-+----+++--++-++++-+----+--+--+-+-+----+++++-+--+-++++-----+-----+++++--------++++++-++-+--+---++-+-+--+-++-+-+++---++++---+--++-+------++++++---+-+-++--++++++++--++--++-++++--++----++---++-+-+-+-+--++--+----++-+--+--++-++++-+-+-------+++-+-+-----+-+--+--+--+--+--+++-++---+--+---+-+-+-++-+----+++-++-+--+++-++-----+-++------++++-++-++-+-+-++--++---+--+--+-+-++--+-+-+-+--+++++-+-++--++++-----+-+--+--+++++++--++++++++++++++++++++++++++++---+-+-+++--++++--+-+---+++--------+-+-+-+--+++---+++--+--+---+++-+-+----+++--++-++++-+----+--+--+-+-+----+++++-+--+-++++-----+-----+++++--------++++++-++-+--+---++-+-+--+-++-+-+++---++++---+--++-+------++++++---+-+-++--++++++++--++--++-++++--++----++---++-+-+-+-+--++--+----++-+--+--++-++++-+-+-------+++-+-+-----+-+--+--+--+--+--+++-++---+--+---+-+-+-++-+----+++-++-+--+++-++-----+-++------++++-++-++-+-+-++--++---+--+--+-+-++--+-+-+-+--+++++-+-++--++++-----+-+--+--+++++++--++++ 505
|
||||
--+--+-+++-+--+--+++-----+--+-+-+-----+-++-++++---++++--+-+--++-+------+-+++----+++-++-+++-+--+-+------+--+-+--+--+---+---+---++++--+---+-++-++--+-+++-+-+-++--+-+----+--+------+++-+-++++-+++++----+-+---+--+-++-+-+++--++--+++--+++++-+---+-+++-++-+-++-++++++++----+-+--+-+++--+--++++-+----+---+-++-++++-++--+-+-++---+------+-++++-+-+-++++--+-+-+--+---------+--++-+------+++++------+-++-++-+--+---+-++-+-+-+++----+++++-+++-+---++-++-++++-+--++-+--+---++-----++-+-++---+---++-++----+----+++--+-+--++-+-+++--+--++--+-+++-+++++++++--++---+++-+-+--+-+--++--+-----+-+-+-+--+---++++---++-+---+++-++----+-++--++-+---+++----+++--++++--+--+-+-++-++-++--+-++++----+-++--++-++-++--+-++--++-+- 137
|
||||
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 2
|
||||
+-++-+++++---++-++++--+-+-++-+-+++-+++-+-+--+--+-+++++++---+-++++---++--+++--+++-+-++----+-+++-+---+-++-+---+-----+-++-+--++++---+-+-+-+-++-----++++-+++-++-++++---++++++++---+-+-+-++-++-+-+-++++++++-+-+---+-+++--++--+-------+++-+----+++--++---++---+-+--++++-+---+-+++-+--+-+++-+++++-+--+-++----+++-+-+-+-+--+++++----+---+--+----+-+------+-+-+-+-++-+-++-+-++--+-+--+---+--++---+----+- 168
|
||||
-+ 2
|
||||
+---++++++++++-----++--++++++++++----------++------+-----++--++++++++-------++++-+----++-+++++----+++-+-----++++--------------++++---------++----------++++----+++++------+++-+--------+-+-++++++-++---+++-------------+++-+++---------++-+-----++++++++++++--------+---+++++------------+++---++-------+++++-+-++++-------+++++++++-----++++-++-+-----++++------++-----+---+---------------------------------------------------+++----------+++++--++----------++++++++++--++++++-+++++--++--------+++++++----+-++++--+-----++++---+-+++++----++++++++++++++----+++++++++--++++++++++----++++-----++++-+---+-++++++++-+-+------+--+++---+++++++++++++---+---+++++++++--+-+++++------------++++++++-+++-----++++++++++++---+++--+++++++-----+-+----+++++++---------+++++----+--+-+++++----++++++--+++++-+++-+++++++++++++ 415
|
||||
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3
|
||||
--+++-+++-+-+-------+++-++--+----+-+--+++--+--+--++++++--+-++-+--+-+++-+++-++-+-++--+------------------------------++---+---+-+-+++++++---+--++-++++-+-++---++-++-++------++-+--+-++-+---+---+--+-+--++- 115
|
||||
-+-+-++---++++++-++++-++++-+--+-----++--+-+-+--+--+---+++-+-+++-++--+--+++--++--+--++-----+---+---+---+++-+-++---+++-++-----+---++++++-+++++--+----+--+----+++---+-+-+++---+-+----+----+---++--++---+++--+++-+-----++-+++--++-+----+-+++--+-+--++---+++-+-+--+-+-++-++-+--++++++-+-+++----+--+--+++++---+-++++---++-++-+-+-++-+--++--------++-+-+-+--++----++-+-++----+++-+--+-++++-++-+++++-+----++++---+++++-+-+-++--+++-+--+++----++---+-+--++--+---+---+--+---+-+-+-+--+++-+-++----+-+-----++-+++-+--+----+-+---+++----++-+-+-++-+--+-+--+--+-+--+++--++-+-++--+-++---+---++--++---+-+-------+--++-------++-+-++-+----++++--++-+-+---++-++-+-+--+++--++++++++++++-+---++-++------+-+--++-+--+-++--++--+++-++--++-++---++-++-----+ 169
|
||||
+---+-+++++---+-+-----+++++++-+++----+-+-+------++-+++-+-+++---+++---+-+++--++--++++------++-+--+----++--++-----++-+----+-----++--+--++++-+++-+-+-++-+++++-----+---++++----++++-+---+++-++--++++--+------++++-+---++++--+++-+++---+-+-++--+-++---++---++---+-+--++++-------+---+--++---+++++--++--++--+------++++-+-++-------+-----++++----+-+---+++ 91
|
||||
+-+-+-+-+ 3
|
||||
-+++-+++--+-+--++---+--+++++++-+-+-+---------++--+--++--+++-+--+----+-+++-+-+-+-+++--+-+-++--+-+--+-++---++---+-++-+++---+++--++--++---++---+++++-+---++-----+---++-+-++-++--+----++-+++----++---++--- 51
|
||||
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 3
|
||||
+-++++-+-+-+++-+-+-+-++-+--+++-+-+++++++++++++++++++++++++++++++++++++-++++++++++++++++++++++++++++++++++++++++++++++-++++-+-+-+++-+-+-+-++-+--+++-+-+++ 116
|
||||
++-+---+++--+-++--+--------+-+-+++++++--++-+-+-+++++-+----+-+-++-+-+-+++-+-+-+---++-+--+++-+-+--+++---+++-+++-+-----+-+---+--+-+++-+--+-++-++--++----+--+-+-+----+++--++-+---++-+-+-+++++---+---+----++-+----+-+++-----+++-+-+-----+-++-+-++-+++--++++-+++-+---+----+++-+----++-+++++++-+++--+++-----++--+-++--+--+++++-+--- 48
|
||||
++++--++-++++-++-+--+--++++--------+--+----+++----++--------+-++-++--++-+---+-++-+-+-++----+++++--++++-+-+++--+-++++--+++---++-+---++-++--+++-+++---++-++--------+---+-++-++--+---+-+--+++---++-+++--+--+++++---+-++++++++++++++++++++++++++++--++-++++-++-+--+--++++--------+--+----+++----++--------+-++-++--++-+---+-++-+-+-++----+++++--++++-+-+++--+-++++--+++---++-+---++-++--+++-+++---++-++--------+---+-++-++--+---+-+--+++---++-+++--+--+++++---+-+ 234
|
||||
-++++++++- 8
|
||||
+----+-------++--++-+-+-+-+++-+-+++---+++++-++++-++-----+---++---+++--+---+++++-+++--++--+----+-+----+-++-+--+---++-++----+-++++++++-+--+-++++------+-+++---++++---+++++--+-++++++-+---++++++-+-++---+--++-+--++-+++++-+-+-+++-+-+--+--++-+-++-++-+-+++----++-+--+++-+--++++-+++-++----+---++---++++-++--++--++-+-++++---++-+--------++++++-----++-+++++----+--++++-+--- 16
|
||||
---------- 5
|
||||
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2
|
||||
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 3
|
||||
++++--+++++--------++----+++++--+++++--+++++++-----+++--+++-++-+++++++++---+++--++--++-++++-++++-+++-++----+---------+----++++---------------------+-+++++++++++++-------++++++--------+-+--+++++++----++--+---+------+++----++----+----+--+-----+-----+++++-----+--++-+++-+-+++--+-++++--++--+-+-++----+++--++-+-++-------++++---++----++-+----+++--+++++-----++-----+++++++--+++---++--++-++++-----+----+--++--++++---+-----++-+++-+-++--++--+++-+-+--+--+-+--+-----+-++-++-++-++-+-++++-+++--++++-+++-++++++++--++----+---+++++----+--+++----+++--++----+---++++++------++--++-+-++--+---++---++--------+++-+++---+--++-+-+-++--++----+++---++-+---+-++-+++---+---+-+-++++-+++----+--+++++-++++++--+--+--++---+--+----+-++--++-++--+-----+++++++++++-++++++-----++-----+++++--+--+++++++++++++----+++---+++--++++--+--++++++++---------+++-++-++++------++--++++-+++++++----+----+-----++-+++--+++--+-++++++-+----+++++++-++--+---------++-++- 182
|
||||
-++++++++- 10
|
||||
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-- 2
|
||||
----+--++-+--+--+---+++-+-+---+-++-++-+--+-+----+-+-++---+++--++---++++-+-+-++--+--++-+--++-+---+--++-+---++---+-+--+-+--+--++-+----+-+-+---++++-+--++++---------++---+-+---+-++-++--++-++-+-+---++++++++----+--+----+----+-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----+--++-+--+--+---+++-+-+---+-++-++-+--+-+----+-+-++---+++--++---++++-+-+-++--+--++-+--++-+---+--++-+---++---+-+--+-+--+--++-+----+-+-+---++++-+--++-+---------++---+-+---+-++-++--++-++-+-+---++++++++----+--+----+----+-+ 688
|
||||
+--+---+--++--++++--+--++--+--+++-+-+-----+-+-+--+--++++-+-+-++-+--++-+++-++++-+---++-++---+--++-++-++------+++++--+-----+-+-+--+---++----+-+-+--++-++-+++-+++---+-+---++---++-++-++-++++-+++--++-++++-+--++-++---+-+-++-----+-+--+-+-+--+++--++++++++-+-+-+--+--++--++-+-++++-+--++++--+++---++-------+--+----+-+----+---++-++-+-+-----+-----+-+-+-++---++---+-+++++----+--+-++---+-++-+--------------++++----+++-+-+---+-+--+--+++-+---+++++-+++++++----+---+---+-+----+++-+----++-+-+--++++-+--+++---+++++-++-+-+--+-+++-++--+-+-+-+-+++++-+-++--+-+++------+-+-+--+-+++++++--++-+-++---+-----+-+++++-++--+++---+++-+----+---+-+-+++--+-+++---+-+--++----++-+++------++-+----------+-+++-+++--+---+++-+++-+--++-++-+++++-++--++-++-+++++-++-+-+++++-+-++-+--+++-++--+++-+-+-+--+++--++-++++-------++-+----+-+++----+--++++--++-+-++-+++--++--+----+--+++++-----++---++-++++---+--+++++--+-++--+---+++++---++-+-----+++-+---+--+---+---+-+-+-+++-++--++-++-+-+--+++---++-+--+------++-+---++-++-+++-+++++-+---------+ 216
|
||||
+++-------------+---+--++++-++++++--++++++--+--+-++---------+++++--+++++---+++++--+---+--+++--+++---++-++--+---+++-+-++++++-++----+-+---++--+-++--+++-------++-++++-+--++--+----++--++++---++-++++++--++-+------++++++-+++++-+-++++-+++--+-+++++---+++--++--+---++--+++++----+++---+-++-+++++++---+++-++++--+---+----+-+----++----++--+++++-+--++---+-+---++++++++++-+----++++-+-----+++--++++++-----+++---++------+++--++--------+--++-++++--++--+----+++------+-++-+-+++---+-++------+---++-+-+++++------+++------+---+++++++++++---+-++++++++---------+---+---+-----------++++++++-++++++++++++ 66
|
||||
+++--++-+-+-+---+++++-++-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--++-+-+-+---+++++-++- 456
|
||||
-+--++-++++-----+-+---+-+-++---++-------++--+-++--+++-+--+--+---++--+-++++--++-++---+------+--+-++++++++---+--+--+------+-+-+---++++++--+---++-++-+--+--++++---++++--+-+-+-++-++-+-++-+++-+--+++-+-++----++--+-+++-++++-+-++-++-+++------+-+++--++----+--+-+--+-++--++-+++--++--+-+---+--+-------+--+-+-+++-++-+----------++--++-+++-+-++++++---+++----++++++++++--+---++--++++-++---+-++++++-+--++++++-+-+-+-------++---+-++----+-+-+++-++-+--+++---++-++-----+--+++-++--+---++--+--++-------++-+-++-----+--++-+--+---+++++++--++-+++-+----+++++-------+++-+-+++++--++--++---+++---+++++++--+----+++-+-++++-+----++-+++-++---+++++--++---+++++-+--+-+---++------++--+----++-+++++--+-++-------++-+++-----++++-----+---+-----+++-+----++-+--+--+-+++-+----+++--++--++++++-++-----++---++++++---++- 112
|
||||
-+++++-----++-----++++++---+-+------+-++++++++++--+++++++++-+--+-+++---++---++--+-+++---++-+-+---++-+-++-+-------++--+-+-+--+++ 24
|
||||
-++++++++---+--------+---------+++----++++-++++++-++--+++-----+-+++++----+--+++++++++++-+++++ 12
|
||||
---++++--+--++---++----++------+-++---++++-++---++-++-++---++++--+-+-+++-+-+--++++--++-+++---++-++++--+++++--+---++++--+--++--+-----++--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---++++--+--++---++----++------+-++---++++-++---++-++-++---++++--+-+-+++-+-+--++++--++-+++---++-++++--+++++--+---++++--+--++--+-----++--++ 788
|
||||
+++++++++++++-------------------++++++++++++++-------------------+++++++++++++++++++++++-----------++++++++++++++++++++---------------+++++++++++++++++------------------------------+++++-----------------------++++--------------------------------------------------------------+++++++++++++++++++++++++++---------------++++--------------++++---------------++++-++----------------+++++++++++------------------+-+++++++++++++++-----------------+++---------++++++------+++++-++++++++++++++++++++++++++--+++-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---++++++++++++++++++++++-----------------++++++++++++++++++++++-------------------+--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------++++++------+++++------+++++++++++++++++++++-----++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------++ 289
|
||||
++++++++++ 10
|
||||
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 1000
|
||||
--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 2
|
||||
++--++-++---++-++--+--+-+-++---++-------+-------+--+--+++--++--+--+-++---+--++-+-++++++--+--+-+--+-++++---+----++--++--+++++-+-+--++++++-+++-----+++--+-+-+----++++--++-+--+++--+++-+--++++-+-+++-++++-+-+-+++-----+-++-----+++++++---+++-++------++-+-+-+-+--+-+----++----------++-++++-+--++++++-+++--+++--+-+-+-+----+++-+-+-++++-----+-+-----+-+++++--+-+--+++--+-+-+--+--+----++-++--+---++-++-+-+---++++++++-+----++--+-+-++-+--+----+---+++-+-+++--++--+-+---+-+-+---+++------++-+---++++++-++-++-+-++--++--+-------+-+-+--++--++++--+--+-+++-+--+--++--++-++--+++-++---+--+-+-+--++---+-++--+--+++-+-++-+-++-+++-+++--++--+-+--+----+---++++++++++-+-+----++++---++---++-+++--+-+------+++++--++--+++----++++++--++--+-+--++++--+++-+-+--+----+++------+----++-++-+-+--+++-+-++-++--+-+++++++++--+---++--+--++ 260
|
||||
---------- 10
|
||||
+-+-+-+ 3
|
||||
++---+-+-++---+--++----+++-+-+-+-+-+--++++++----+-+++---+--+-+-++--+---++-++++--+-----++++-+--+------++++-+++--+--+++--+++--+--+-++-++--+++--+++---++++-+++++-++-+--+++++-----------++++--++--+-+---+-+-+---++-+-++++++--+-+-+++---++-++++-++--+--+--+-++----++----+---++-+++-+++----++-+++++++-----++-+++++++---------++++++++++-----+-+-----++++-++---+--++-+-+----++-+-++-----+-++++-+++-------+++++-+++-+---+++-+--+++--+--+--++++----+++--+-+-+--++-++---+-++-+++++-+-++--++--+---+--+--+-+--++-+-++-+--+++++++++-+++++++++------+++--++++---+-+----++-+-+-+----++-+-+--+--+---+-+++-+-++-+--+++----+- 34
|
||||
-- 2
|
||||
+-+-+-+-+- 2
|
||||
--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+ 3
|
||||
++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++-++- 3
|
||||
-+-+-+--+--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-+-+-+--+-- 131
|
||||
+-+-+-+-+- 3
|
||||
+++++++++++-+--------+++++---++++++----------------+++++------------++++++++++++++++++++--++++++++-----+++--++++---+--++++++++++-----++++---+++++-++++++++++++++------+++++---+++++++++++++-------+----------------++++++------+++-----------+++--------+++-----+++--+--+--++++----------------+---+-----------+------+++++++----------------+++--++++--++++++++++++++++++++-----++++++++++++------++++++++++++++++ 77
|
||||
--+++++--++---+--++-+-++--+++++--+-+-----++++-+-+---+--+----++---+--+-+------------------------------------------------------------------------------------------------------------------++-----++--+++-++--+-+--++-----++-+-+++++----+-+-+++-++-++++--+++-++-+-++ 185
|
||||
-+++++++++ 2
|
||||
-++++++++- 9
|
||||
-+----++-+-+++-+--++----+++-++--+-++-+--+-+-+-+--+-++--++----+------+++++---++-+-+-+-++++--+---++--+---------+---++-++++-+++++-----+++-++--+-++++-++-----+--+-++++--++++-+-++-+++++----+---++++--++-----++++++-+++-+++-----------------------------------------------------------------------------------------------------------------------+-++++--+-+---+-++--++++---+--++-+--+-++-+-+-+-++-+--++--++++-++++++-----+++--+-+-+-+----++-+++--++-+++++++++-+++--+----+-----+++++---+--++-+----+--+++++-++-+----++----+-+--+-----++++-+++----++--+++++------+---+--- 333
|
||||
-+--+++++-+----++-++-+---+-++--++-+-+---++-----++++++--++-----+++++++++--+---+-++-++-++--+--+---+++++-+----++++---+-+-+--++---++++++-++-+--++++-+++++++--+---+-+-+-+-++-+-+---+-++--+-++----+-+--+--++++-+-+--++--++---+-++--+++-+---+-+----++++-+-++-+---+-++----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+-++-----+-++++--+--+-+++-+--++--+-+-+++--+++++------++--+++++---------++-+++-+--+--+--++-++-+++-----+-++++----+++-+-+-++--+++------+--+-++----+-------++-+++-+-+-+-+--+-+-+++-+--++-+--++++-+-++-++----+-+-++--++--+++-+--++---+-+++-+-++++----+-+--+-+++-+--++++- 481
|
||||
-++++++------+--++-++++----+++++-+++-++-++++++----+++------------+++++--------------------------------+-------+++++++++++---+++++++---+++-----------+++++-----------++++-++++++++++++++-+++------+++++++-+++++------++++++---++---+++++-+--+-++++++++---+++++++-+--+++--+---+--++----+----++++-++++---+--++-+---+--++----++---+-----++--------------+-----++++++++++++--+++--+++++++++++---+++++++---+++-----------+++++-----------++++-++++++++++++++-+++------+++++++-+++++------++++++---++---+++++-+--+-++++++++---+++++++++--+++++-+++++++++---+++++++++--++++-----++-++++---+-+-++--+++-+----+-++++++++++++++-+++++-----------+++---+++++++++ 255
|
||||
-++++++++- 2
|
||||
-+-++---++--+++-+--++--+++++-+-+------+-+++++--++----+-+++-++--+-+--+---+--+----+--+-+-+-+---+--+-++++--++----+-++---+-+-++-+------+---+++--+------+++-+--- 57
|
||||
-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-+ 2
|
||||
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 999
|
||||
-++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 2
|
||||
+------++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++------+++ 90
|
||||
---+----+-+---+++-+-----++-++--+++++-+++-------+-++++++++-+--+--+++--++-+-+-++++-+--+++--++++-+-----+--+-++--++--+----+-----++--+-++++--++--+-++++-++----+++------+-+++--+---++++-+--++-+++-+++----++++++-+-+-+-+++++--+---+---------+-++---++++-++++-+-+-+-----+-++--++--+--++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---+----+-+---+++-+-----++-++--+++++-+++-------+-++++++++-+--+--+++--++-+-+-++++-+--+++--++++-+-----+--+-++--++--+----+-----++--+-++++--++--+-++++-++----+++------+-+++--+---++++-+--++-+++-+++----++++++-+-+-+-+++++--+---+---------+-++---++++-++++-+-+-+-----+-++--++--+-- 527
|
||||
--------- 3
|
||||
+- 2
|
||||
-+++-+++-++------+-+--+--++++-----+--+-+-+++-+-++--+----+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+---+---+--++++++-+-++-++----+++++-++-+-+---+-+--++-++++- 818
|
||||
+--------+-------- 9
|
||||
+-+-+-+- 3
|
||||
-+++++++-+ 2
|
||||
-+-+-+-+-+ 2
|
||||
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 20
|
||||
-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+ 3
|
||||
----+--+---+--+++-+-++++-+---+++---+---+++-+++++---+-+--++-+---+-+---+--+-++-++++--+--+++-++++++++--++++---+-++++---+-+----+-+-++-+--+++-+--+-++--------+---++-++++++++--+--+--+-----+-+-----+------+-++-+------++--++---+--++-+-++-+-++++--+----+++----++--++-++-+-----+--++---+-----++-+-+--++-++++-++--+-+++++---+--+-+--+++++--++-+--+-+++--++--+---++++---++-+----+---+++++++--+-+------++-+-+++-----++++++-++++-+---+++------++-----+++-++-+-+--+++--+++-++--++---+--++-+---+-------+-+---------+-+--+------+---+--+++--+--+-+-++--+-+-++++++--+-+----+-+--+-+-++--++--+---+++-++--+++-+-+++--+++---+++++++-------++--++---++----+---++++--+-+-++---+++---+------+++----++----+-+-+-+-+++++++++++++--+++++++--+++-++---+-+++-+--+-----++-+-++++-++-+++--+-+--+------++---+------+--+-++-+-++-++--+++-+-+-+++-+-+-+-+-++--+-++++--+++--++-+----+-+-+--+++-+---+++---+----+-+++++++-------+-+- 229
|
||||
--++--++-++-+++-++--++++--+-+-++-++--+--+---+--++------+++-+++++++--++--++-++-+++-++--++++--+-+-++-++--+--+---+--++------+++-+ 66
|
||||
+++++--+-+------+++--+---------+++++++++-++++++-+++------++--------++++-++++++---+-+++-----++++-+-+-+------+-++++-+-++++-+--------+++----+-++-+++++++--+--++++++-+--+---+---+--+-----+-+++-----+++++-+-++++-+---+-+++---+------++++--+++-----++--+++-++---+++--+++-+-++-+--++-+-+-------------++-+-+---++++-++-+++-----++++++----------++---+-+--++++---++---++++-+++--+-----+++++-+++-+--+----+-++-++++-----+----------+--+--+++++----+-------++-+-+++-+-++++--++++---+++++-+++-++++-+++-++-+++--+++++-----------+--+--+++--++++++++-------+---+++-++++--+++-++ 90
|
||||
++-++-++-++--++--++-+-+++--+++-++-------++++---++-+-+-+-+-+--+--+++-+-+-+-+----+---+--+++--++--+---+--+-+-++-----+-+----+-++--++-+---++-+-+----+-+++--+-+++++-++-+----++---+++++++--+-+--++-++-++-+-----+-++++++++++-++-+-+-++++-+-++--+--+-+----++-++---+-++-+-++-++-++---++++-----+--++-++--+++++-+-+---+-+-+++++--++-++-+++-++++-+++++-+++--+-++-+++++---++++--+----+++++---++-+-++--+--++-+++-++++---+++-+++-++++++--+++---+++++--+-+-+-+---+-++-+------++++--+-+-+--++-+-++--++-++--+--+-++-+-++-++---+-++-+--++-+++-+-----++---+--+-+++++-+-+-+----+++++-+---+++++---+++--+--+++--+++--+-++---+-++-+++-+++---++-+----+---+----++-+--+----++++-+-+-+--+-+++--------+-------+++++++++-----+-----+++-+- 86
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 500
|
||||
-++-++++-++-+-+---+++++++++--++--+-++-++-+-++++++-++--++-++----+-+--+-+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-++++++++++++++++++++++++++++++++++++++++-++-++++-++-+-+---+++++++++--++--+-++-++-+-++++++-++--++-++----+-+--+-++ 498
|
||||
---------- 2
|
||||
+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ 998
|
||||
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- 1000
|
||||
++--++--++++--++-+++---+++-+-+-+---+--+--+-+---++-------+++-++-+----++-----+++-+----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------++--++----++--+---+++---+-+-+-+++-++-++-+-+++--+++++++---+--+-++++--+++++---+- 586
|
||||
---------- 3
|
||||
--++--+--++--++---+------+++++-+++-+-+++++----+-+++--+---++----++-++-++-+--+--++-+-+++++-----+-++++-++-++++--++-+++-------+++-++-++++-+-+++-+------+-+--+-+++---+++--+-+--++++++++-------+--++-------++++-++----+--++--+--++--++---+------+++++-+++-+-+++++----+-+++--+---++----++-++-++-+--+--++-+-+++++-----+-++++-++-++++--++-+++-------+++-++-+++--+-+++-+------+-+--+-+++---+++--+-+--++++++++-------+--++-------++++-++---- 209
|
||||
--++----+-++--++--+--++++++----+------+---+-+-++++--+--+-+-++--+-+---+-+-++-++-+++--++-+--++--+++++---+-++-+-----++---++-+--+++++--+-+++----------+--------+--+-++----+------++-++++-+-+++--++++-+----+---+----+----+-+---+---++-+-+--+++-++-+++++-+-+-++-+---++-+++----++++-++-+++++---+-+-+--++-++-+-+++--+--+---+--+--+-++----++-+--+-+-+--++--+-+-++--+----+-+--++---+---+-+-+-----+-++------++-+-+---+-++-+--+++++++-+---+-----++++++++-+--+++----+-+--++--+-++--+++-+--+++--+-+--+-+-+++++-++-++-+--+--+++++--++------++-+-----++------+-+----+--+--+--++++-+-+++-++--+-+--+++++--+--+++-++--+--+++++--+-+-+--++-+---++++-+-++---++---++-+-+--------+++-++---+-++--++--++++--+-+---++++----++---+-+--+-++---+-++++-++-+++--+-+-+++++---+++++---+-+-+-+---+++-+-++-----++-+++----++-------+--+++++-+--+++++++-++++-+---++--+--++--+--+-+++++-+-+++--++-+--++++---+----++-++++-+++--+----++++---++++--------+----+---+--------+--+----+-++++-+-++--++--+----+-++---++ 36
|
||||
++-+-++-+-++-+----+---++-++-++------++-++++--+-++--+-----++-+++--+-+--+----+-----++-+++--+-+--+++-+--++-+--++++--+--+++-+++--+++--+-+---+-+-+-+--+---++--++--+++++--++++++-+-+---++++++--+----++-+--++-+++++--+---++-+-++-++++-+++++--+---++-+-++---+-++--+-++----++-++---+---++---++-+-+++-+-+-+-++-++++--+-++---+-+--+-+++-+++--++ 147
|
||||
+++-++-+---++--+++++-+-+--+-+-+--+--++-++-+--+++------+++--+--+----+++-++--+++-+++++++--++--++--++--+++-+++-+--++--+++++-+-++--+---++++++-++-++++-+-+-++--+--++--++++-+-----+-+---++++--+-+++---++++-+-+-+---+-+--+-++-++-++++-+-+--++++++----+--++-+-++-+----+++--+---++-++++++++-+-+++--+++-++++--+--+-------+-+---+---+-+-++---+---+++----+++--+++-++++++-+--+-+++--+++-+++-+++-++--+--+----++++-++++++++-++---+--+-+---+--++++++-+-+++++-+-+-++-+++-+------+--+--+---++--+---++++-++----++++--+-+--+++-+++-+-+++-+++++-+++++-+++-++++-+++++++--+-+--+-+-+-++-+++----++--++---+-+-+++--+-++-+------+----+--+++-++-++++-----+-+++--++++-++--++-------+-+--+++++++-+++-+-+--+---+-++++-+-++-++-++-+-+--++++-+-----++-++++----+-++--+-+---+++++++++-++--+---+---++++++--++---+++-+++-++--+-+-+-+--+++-+--+--+-++-+ 242
|
||||
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1000
|
||||
++++++++++-----------++++++++++---------++-+++++++++++++++---+-+++++-------+------+++++-+++++++++++++------++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------------------+++++++++++----------+++++++++--+---------------+++-+-----+++++++-++++++-----+-------------++++++------+++ 562
|
||||
++ 2
|
||||
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+- 2
|
||||
++---+-++++-+-++-----+---+----+-+--+++++-----++++++++++---------+++--+--+-+++-++----++-++++++++---+-+--++ 21
|
||||
--+-++++-++++--+++++++-+--++-+-+-+-+-++--++--+--+++-----++-++++-+-+++-+--+++---++----+-+-+---+---++--+++----++-+-++-+++---+++-+++--++---+-++---+---++----+++--+----+++++-++++-++++---+-++--++---+-+++++-++---++++-+++++-+++++-++-+--++++-+-+-+---+---+-+---+-+--++-------++-++--+--++-+++-++-++++++--+++-++-+-+++--++-----+++--++++-+--++--++--+--+---++-++-+--+---++-+--+-++-+--++---+-++-++++-+----+++++++----+---+-++---+++++++----+++++-++--+++++---+-++-----+++++--++-+--+----++--+-++----------+++++++++-++++++---------+++--++++-+--++-----+--++-+---+--+--+++-+++++++++--++-+-+-++-+-++--++++---+-++-+-++--++++-+-+---+-+++--++-+----+-+--+- 80
|
||||
-+++++++-- 2
|
||||
+++-----++-++----++--+--+---+-+---++-++-+++-++-+---+--++++--+++---++-+++-+--+-+--++++---+--+-+---++-++-++-+-++-++-+-+-------++--+++++----+++++--+--++---+-+---++-+----++---+--------+--+-+-+----+--++----++-+---++++-++-++-+----+-++-++-+-++-++---+-+-+-+++----++++++-++--+-+----+--+--+++---+-++-++-----+---++----+----++-+--+-+++++----+--+++--+--++--+-+++--++++-++--+--+----+++----++--++-+-+---+++-++++-+--+-++-+-+++++-+++-+++--++--+-----++--+---+-+----+--+++--+++--+-------+-+-+--++---+++++---++++-+---+-++--++--++-++---+-+-+-++-++++---+-++-+-+--++++-+-+-++-+-+++-+-+-+++++-+----++++----++-+-++---+-+++++++++-+-+-+-++--+-+++++-+-+-++++-+--++-+++-++--+--++---++--++---+ 97
|
||||
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.TaskA
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.04.08
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
53
archive/2017.04/2017.04.08 - unsorted/TaskB.java
Normal file
53
archive/2017.04/2017.04.08 - unsorted/TaskB.java
Normal file
@@ -0,0 +1,53 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.GCJSolution;
|
||||
|
||||
|
||||
public class TaskB extends GCJSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
long parse(char[] s) {
|
||||
return Long.parseLong(new String(s));
|
||||
}
|
||||
|
||||
boolean isGood(char[] s) {
|
||||
char[] s2 = Arrays.copyOf(s, s.length);
|
||||
Arrays.sort(s2);
|
||||
return Arrays.equals(s, s2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
char[] s = in.nextString().toCharArray();
|
||||
|
||||
List<char[]> vars = new ArrayList<>();
|
||||
|
||||
vars.add(Arrays.copyOf(s, s.length));
|
||||
|
||||
for (int i = 0; i < s.length; i++) {
|
||||
char[] s2 = Arrays.copyOf(s, s.length);
|
||||
|
||||
if (s[i] >= '1') {
|
||||
s2[i] = (char) (s[i] - 1);
|
||||
for (int j = i + 1; j < s.length; j++) {
|
||||
s2[j] = '9';
|
||||
}
|
||||
vars.add(s2);
|
||||
}
|
||||
}
|
||||
|
||||
vars = vars.stream().filter(this::isGood).sorted((o1, o2) -> Long.compare(parse(o1), parse(o2))).collect(Collectors.toList());
|
||||
|
||||
out.println(parse(vars.get(vars.size() - 1)));
|
||||
}
|
||||
}
|
244
archive/2017.04/2017.04.08 - unsorted/TaskB.task
Normal file
244
archive/2017.04/2017.04.08 - unsorted/TaskB.task
Normal file
@@ -0,0 +1,244 @@
|
||||
5 TaskB
|
||||
12 MULTI_NUMBER
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
3
|
||||
0
|
||||
31 4
|
||||
132
|
||||
1000
|
||||
7
|
||||
111111111111111110
|
||||
65 Case #1: 129
|
||||
Case #2: 999
|
||||
Case #3: 7
|
||||
Case #4: 99999999999999999
|
||||
|
||||
|
||||
1
|
||||
1
|
||||
394 100
|
||||
132
|
||||
1000
|
||||
7
|
||||
813
|
||||
761
|
||||
1
|
||||
248
|
||||
309
|
||||
449
|
||||
627
|
||||
137
|
||||
967
|
||||
269
|
||||
388
|
||||
646
|
||||
859
|
||||
443
|
||||
8
|
||||
708
|
||||
108
|
||||
633
|
||||
609
|
||||
781
|
||||
404
|
||||
65
|
||||
179
|
||||
228
|
||||
897
|
||||
210
|
||||
982
|
||||
636
|
||||
87
|
||||
246
|
||||
140
|
||||
220
|
||||
759
|
||||
805
|
||||
999
|
||||
706
|
||||
325
|
||||
586
|
||||
429
|
||||
278
|
||||
512
|
||||
129
|
||||
684
|
||||
562
|
||||
870
|
||||
490
|
||||
470
|
||||
638
|
||||
263
|
||||
701
|
||||
328
|
||||
591
|
||||
339
|
||||
201
|
||||
677
|
||||
938
|
||||
343
|
||||
595
|
||||
687
|
||||
607
|
||||
574
|
||||
271
|
||||
387
|
||||
459
|
||||
226
|
||||
744
|
||||
621
|
||||
187
|
||||
525
|
||||
634
|
||||
273
|
||||
522
|
||||
846
|
||||
703
|
||||
698
|
||||
368
|
||||
773
|
||||
451
|
||||
655
|
||||
244
|
||||
229
|
||||
232
|
||||
180
|
||||
175
|
||||
943
|
||||
434
|
||||
456
|
||||
93
|
||||
341
|
||||
66
|
||||
746
|
||||
569
|
||||
842
|
||||
70
|
||||
331
|
||||
427
|
||||
363
|
||||
|
||||
-1
|
||||
1
|
||||
2
|
||||
1435 100
|
||||
132
|
||||
1000
|
||||
7
|
||||
111111111111111110
|
||||
52233344555577889
|
||||
11213455578
|
||||
441
|
||||
112344556994475697
|
||||
11112244441
|
||||
290752954014001643
|
||||
1110109208
|
||||
3123444578
|
||||
4123345689
|
||||
319078819330167357
|
||||
729464470438415066
|
||||
56497687766494867
|
||||
531309546354305306
|
||||
812233344455677888
|
||||
338
|
||||
23755577788899
|
||||
31113456667900
|
||||
998785093824284001
|
||||
307966583387361360
|
||||
661400997472920416
|
||||
1111111012
|
||||
112222132449759484
|
||||
11111111222220366
|
||||
82223345667778888
|
||||
1737397363
|
||||
12233335566557955
|
||||
201939802410664807
|
||||
36556667888899
|
||||
9899999999
|
||||
497897495749774791
|
||||
11156888899945
|
||||
16890335899
|
||||
1113123666
|
||||
206
|
||||
134881440096862376
|
||||
18099857461
|
||||
76766679878787
|
||||
8
|
||||
83
|
||||
952517863572053653
|
||||
1000000000000000000
|
||||
269090516837409607
|
||||
1122233317
|
||||
11111111111111106
|
||||
364162038890924619
|
||||
900901988555113906
|
||||
1
|
||||
32999999999999
|
||||
1111111110
|
||||
941721579920721938
|
||||
405592356612716516
|
||||
76999999999999999
|
||||
235683911930341210
|
||||
13444556736
|
||||
65999999999
|
||||
71222335677887
|
||||
585797590520470246
|
||||
11223555527349
|
||||
704276516572886869
|
||||
109999999999999999
|
||||
359268530677407719
|
||||
73334445677888999
|
||||
141244455556688899
|
||||
76
|
||||
207224293494964588
|
||||
870614541780094049
|
||||
112344444555666900
|
||||
804655777964741391
|
||||
748645996657567575
|
||||
703694394993403637
|
||||
11111111111111110
|
||||
167995856995777657
|
||||
879
|
||||
11111334566789
|
||||
111112223344455503
|
||||
23444422578
|
||||
999999999999999999
|
||||
246
|
||||
11222255519443347
|
||||
31111134557788898
|
||||
81446667900
|
||||
41223336888
|
||||
93345677779
|
||||
82
|
||||
8389648799
|
||||
340
|
||||
33556666899
|
||||
439119571286482627
|
||||
45
|
||||
412223334557778899
|
||||
257708970528993425
|
||||
32
|
||||
12551123444679
|
||||
5224567890
|
||||
11111122223330
|
||||
899889122355696633
|
||||
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.TaskB
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.04.08
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
48
archive/2017.04/2017.04.09 - unsorted/TaskC.java
Normal file
48
archive/2017.04/2017.04.09 - unsorted/TaskC.java
Normal file
@@ -0,0 +1,48 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.SortedMap;
|
||||
import java.util.TreeMap;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.GCJSolution;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskC extends GCJSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
void add(SortedMap<Long, Long> map, long x, long c) {
|
||||
map.putIfAbsent(x, 0L);
|
||||
map.put(x, map.get(x) + c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
long n = in.nextLong();
|
||||
long k = in.nextLong();
|
||||
|
||||
long c = 0;
|
||||
|
||||
SortedMap<Long, Long> map = new TreeMap<>();
|
||||
map.put(n, 1L);
|
||||
|
||||
while (true) {
|
||||
long l = map.lastKey();
|
||||
long lc = map.get(l);
|
||||
map.remove(l);
|
||||
|
||||
if (c + lc >= k) {
|
||||
out.println((l / 2) + " " + ((l - 1) / 2));
|
||||
return;
|
||||
}
|
||||
c += lc;
|
||||
|
||||
add(map, l / 2, lc);
|
||||
add(map, (l - 1) / 2, lc);
|
||||
}
|
||||
}
|
||||
}
|
357
archive/2017.04/2017.04.09 - unsorted/TaskC.task
Normal file
357
archive/2017.04/2017.04.09 - unsorted/TaskC.task
Normal file
@@ -0,0 +1,357 @@
|
||||
5 TaskC
|
||||
12 MULTI_NUMBER
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
5
|
||||
0
|
||||
30 5
|
||||
4 2
|
||||
5 2
|
||||
6 2
|
||||
1000 1000
|
||||
1000 1
|
||||
68 Case #1: 1 0
|
||||
Case #2: 1 0
|
||||
Case #3: 1 1
|
||||
Case #4: 0 0
|
||||
Case #5: 500 499
|
||||
1
|
||||
1
|
||||
122 4
|
||||
1000000000000000000 123
|
||||
1000000000000000000 123123
|
||||
1000000000000000000 123123213
|
||||
1000000000000000000 1000000000000000000
|
||||
-1
|
||||
0
|
||||
2
|
||||
769 100
|
||||
4 2
|
||||
5 2
|
||||
6 2
|
||||
1000 1000
|
||||
1000 1
|
||||
901 690
|
||||
420 404
|
||||
869 825
|
||||
999 487
|
||||
1000 127
|
||||
2 2
|
||||
338 283
|
||||
999 512
|
||||
999 999
|
||||
999 495
|
||||
986 774
|
||||
999 255
|
||||
845 684
|
||||
500 127
|
||||
711 552
|
||||
958 880
|
||||
1000 128
|
||||
3 1
|
||||
1 1
|
||||
5 1
|
||||
837 830
|
||||
999 998
|
||||
4 1
|
||||
437 418
|
||||
257 253
|
||||
361 281
|
||||
500 2
|
||||
500 500
|
||||
500 1
|
||||
500 244
|
||||
999 511
|
||||
874 660
|
||||
269 240
|
||||
500 246
|
||||
1000 488
|
||||
1000 511
|
||||
999 128
|
||||
999 499
|
||||
879 766
|
||||
1000 999
|
||||
500 248
|
||||
500 174
|
||||
944 792
|
||||
1000 495
|
||||
1000 2
|
||||
500 245
|
||||
1000 256
|
||||
999 497
|
||||
290 280
|
||||
748 659
|
||||
414 396
|
||||
500 255
|
||||
650 590
|
||||
1000 489
|
||||
610 522
|
||||
500 116
|
||||
999 1
|
||||
999 467
|
||||
405 368
|
||||
668 545
|
||||
999 2
|
||||
802 670
|
||||
720 583
|
||||
844 827
|
||||
500 117
|
||||
999 127
|
||||
999 488
|
||||
355 342
|
||||
1000 500
|
||||
1000 421
|
||||
640 563
|
||||
2 1
|
||||
500 256
|
||||
500 128
|
||||
1000 512
|
||||
338 321
|
||||
500 74
|
||||
760 612
|
||||
341 268
|
||||
500 249
|
||||
3 2
|
||||
610 532
|
||||
1000 498
|
||||
923 732
|
||||
963 905
|
||||
847 782
|
||||
999 256
|
||||
500 499
|
||||
500 250
|
||||
788 675
|
||||
1000 255
|
||||
999 498
|
||||
703 563
|
||||
1000 499
|
||||
592 462
|
||||
|
||||
-1
|
||||
0
|
||||
3
|
||||
1263 100
|
||||
4 2
|
||||
5 2
|
||||
6 2
|
||||
1000 1000
|
||||
1000 1
|
||||
821275 662896
|
||||
370621 322685
|
||||
500000 128
|
||||
999999 475712
|
||||
999999 128
|
||||
999999 499998
|
||||
896945 811342
|
||||
431393 425890
|
||||
381788 365508
|
||||
942120 863910
|
||||
621693 498655
|
||||
1 1
|
||||
904816 901671
|
||||
500000 237857
|
||||
300739 297343
|
||||
500000 172962
|
||||
1000000 262143
|
||||
734360 697121
|
||||
500000 249998
|
||||
999999 475711
|
||||
500000 500000
|
||||
450609 408867
|
||||
999999 2
|
||||
500000 2
|
||||
500000 127
|
||||
725952 689643
|
||||
572847 446591
|
||||
500000 499999
|
||||
1000000 127
|
||||
999999 457010
|
||||
1000000 500000
|
||||
849170 739229
|
||||
771396 752436
|
||||
344361 268764
|
||||
511147 390215
|
||||
999999 499999
|
||||
999999 127
|
||||
1000000 487852
|
||||
999999 489660
|
||||
1000000 499999
|
||||
3 2
|
||||
500000 250000
|
||||
872095 684924
|
||||
999999 262143
|
||||
874339 839950
|
||||
999999 999998
|
||||
1000000 475712
|
||||
1000000 1000000
|
||||
500000 249999
|
||||
646961 635502
|
||||
5 1
|
||||
570324 507670
|
||||
1000000 128
|
||||
268384 216076
|
||||
1000000 499998
|
||||
999999 524287
|
||||
407340 375069
|
||||
2 1
|
||||
851352 644003
|
||||
1000000 475713
|
||||
3 1
|
||||
519729 498412
|
||||
999999 499997
|
||||
1000000 999999
|
||||
500000 131072
|
||||
333275 315459
|
||||
977626 794616
|
||||
523053 411776
|
||||
500000 262143
|
||||
891025 770291
|
||||
1000000 262144
|
||||
640392 499350
|
||||
999999 524288
|
||||
999999 1
|
||||
2 2
|
||||
500000 237856
|
||||
616030 555591
|
||||
756266 717556
|
||||
1000000 413449
|
||||
385916 360831
|
||||
358463 333483
|
||||
500000 238557
|
||||
1000000 1
|
||||
416201 402940
|
||||
4 1
|
||||
500000 262144
|
||||
500000 131071
|
||||
1000000 2
|
||||
1000000 524287
|
||||
999999 262144
|
||||
347025 305672
|
||||
999999 999999
|
||||
689239 609335
|
||||
1000000 524288
|
||||
500000 1
|
||||
|
||||
-1
|
||||
0
|
||||
4
|
||||
3232 100
|
||||
4 2
|
||||
5 2
|
||||
6 2
|
||||
1000 1000
|
||||
1000 1
|
||||
500000000000000000 127
|
||||
500000000000000000 144115188075855872
|
||||
699326990685848072 680635305377535354
|
||||
500000000000000000 163740560308998749
|
||||
381427200931521728 346261337476093587
|
||||
999999999999999999 423539247696576512
|
||||
1000000000000000000 499999999999999999
|
||||
865421098959557555 684155182903419004
|
||||
360917918673087341 303601411776435264
|
||||
1000000000000000000 128
|
||||
999999999999999999 127
|
||||
887304098876408148 859546197722969838
|
||||
1000000000000000000 527914014562736920
|
||||
3 2
|
||||
500000000000000000 143500374754088600
|
||||
500000000000000000 250000000000000000
|
||||
658959080646161996 525500399070216400
|
||||
607155866659799059 478808602542666155
|
||||
384929880583945989 322262197235520868
|
||||
5 1
|
||||
259330858147696499 199327637605439133
|
||||
1000000000000000000 423539247696576512
|
||||
1000000000000000000 127
|
||||
732760568021509086 618127296652689174
|
||||
1000000000000000000 2
|
||||
3 1
|
||||
1 1
|
||||
500000000000000000 211769623848288256
|
||||
500000000000000000 249999999999999999
|
||||
502627534851421451 468903173610277009
|
||||
601191797848932721 548168387726018986
|
||||
999999999999999999 329367277327674123
|
||||
575159299148999951 528582889012600303
|
||||
856750160143332645 664434146050029993
|
||||
2 2
|
||||
1000000000000000000 500000000000000000
|
||||
999999999999999999 423539247696576511
|
||||
707990425632737172 663859474706555763
|
||||
2 1
|
||||
999999999999999999 576460752303423488
|
||||
999999999999999999 2
|
||||
868779697169149743 664224330639358108
|
||||
999999999999999999 499999999999999997
|
||||
795983503314000778 781519297029362768
|
||||
4 1
|
||||
500000000000000000 243197388029012199
|
||||
500000000000000000 128
|
||||
999999999999999999 288230376151711744
|
||||
1000000000000000000 288230376151711744
|
||||
500000000000000000 211769623848288257
|
||||
999999999999999999 499999999999999999
|
||||
999999999999999999 284008158727382839
|
||||
735221576388427970 621351543070068507
|
||||
500000000000000000 288230376151711743
|
||||
812245689558992791 779051157379015731
|
||||
365396181115446694 332120320444002379
|
||||
533883865169233759 448869823804426904
|
||||
999999999999999999 999999999999999999
|
||||
1000000000000000000 368753975369197209
|
||||
1000000000000000000 1
|
||||
1000000000000000000 576460752303423487
|
||||
500000000000000000 144115188075855871
|
||||
997509696692707666 857737495006784946
|
||||
500000000000000000 1
|
||||
1000000000000000000 288230376151711743
|
||||
742770676193676566 717591306620485391
|
||||
900060051083134558 855374461530273050
|
||||
1000000000000000000 576460752303423488
|
||||
1000000000000000000 999999999999999999
|
||||
1000000000000000000 499999999999999998
|
||||
999999999999999999 538423766738945342
|
||||
500000000000000000 499999999999999999
|
||||
1000000000000000000 423539247696576513
|
||||
500000000000000000 2
|
||||
999999999999999999 576460752303423487
|
||||
418620651229100384 347964917583558534
|
||||
999999999999999999 499999999999999998
|
||||
413661162123781364 386134670643293570
|
||||
982940613601891396 779774005848863932
|
||||
999999999999999999 1
|
||||
999999999999999999 288230376151711743
|
||||
494695569001444768 415274375890824505
|
||||
500000000000000000 249999999999999998
|
||||
1000000000000000000 1000000000000000000
|
||||
744566784267451322 595932167209774263
|
||||
999999999999999999 999999999999999998
|
||||
645924560384020297 514400404428734131
|
||||
571961719311704536 434563032656917709
|
||||
500000000000000000 288230376151711744
|
||||
1000000000000000000 287010051740529317
|
||||
787428860511543624 693975536748743635
|
||||
841980470699998239 678129661777325429
|
||||
580224443060375196 444847741719779338
|
||||
500000000000000000 500000000000000000
|
||||
999999999999999999 128
|
||||
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.TaskC
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.04.09
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
44
archive/2017.04/2017.04.16 - unsorted/TaskA.java
Normal file
44
archive/2017.04/2017.04.16 - unsorted/TaskA.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package chelper;
|
||||
|
||||
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();
|
||||
|
||||
int[][] a = new int[n][m];
|
||||
|
||||
int c = 1;
|
||||
|
||||
for (int i = 0; i < 100; i++) {
|
||||
for (int j = 0; j < 100; j++) {
|
||||
int x = i - j;
|
||||
int y = j;
|
||||
|
||||
if (x < 0 || y < 0 || x >= n || y >= m) {
|
||||
continue;
|
||||
}
|
||||
|
||||
a[x][y] = c;
|
||||
c++;
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < m; j++) {
|
||||
out.print(a[n - 1 - i][m - 1 - j] + " ");
|
||||
}
|
||||
out.println();
|
||||
}
|
||||
}
|
||||
}
|
31
archive/2017.04/2017.04.16 - unsorted/TaskA.task
Normal file
31
archive/2017.04/2017.04.16 - unsorted/TaskA.task
Normal file
@@ -0,0 +1,31 @@
|
||||
5 TaskA
|
||||
12 MULTI_NUMBER
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
1
|
||||
0
|
||||
9 2
|
||||
2 3
|
||||
3 2
|
||||
27 6 4 2
|
||||
5 3 1
|
||||
6 4
|
||||
5 2
|
||||
3 1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.TaskA
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.04.16
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
176
archive/2017.04/2017.04.16 - unsorted/TaskB.java
Normal file
176
archive/2017.04/2017.04.16 - unsorted/TaskB.java
Normal file
@@ -0,0 +1,176 @@
|
||||
package chelper;
|
||||
|
||||
import java.math.BigInteger;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
import misc.Stuff;
|
||||
|
||||
|
||||
public class TaskB extends SimpleSavingChelperSolution {
|
||||
|
||||
static class Fraction implements Comparable<Fraction> {
|
||||
public final long a;
|
||||
public final long b;
|
||||
|
||||
public Fraction(long a, long b) {
|
||||
if (b < 0) {
|
||||
a *= -1;
|
||||
b *= -1;
|
||||
}
|
||||
|
||||
if (b == 0) {
|
||||
throw new IllegalArgumentException();
|
||||
}
|
||||
|
||||
if (a == 0) {
|
||||
this.a = 0;
|
||||
this.b = 1;
|
||||
return;
|
||||
}
|
||||
|
||||
long g = Math.abs(Stuff.gcd(a, b));
|
||||
this.a = a / g;
|
||||
this.b = b / g;
|
||||
}
|
||||
|
||||
public Fraction add(Fraction o) {
|
||||
return new Fraction(a * o.b + o.a * b, b * o.b);
|
||||
}
|
||||
|
||||
public Fraction negate() {
|
||||
return new Fraction(-a, b);
|
||||
}
|
||||
|
||||
public Fraction subtract(Fraction o) {
|
||||
return add(o.negate());
|
||||
}
|
||||
|
||||
public Fraction multiply(Fraction o) {
|
||||
return new Fraction(a * o.a, b * o.b);
|
||||
}
|
||||
|
||||
public Fraction inverse() {
|
||||
return new Fraction(b, a);
|
||||
}
|
||||
|
||||
public Fraction divide(Fraction o) {
|
||||
return multiply(o.inverse());
|
||||
}
|
||||
|
||||
public boolean isDivisibleBy(Fraction o) {
|
||||
Fraction d = divide(o);
|
||||
return d.b == 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Fraction o) {
|
||||
Fraction d = subtract(o);
|
||||
return Long.compare(d.a, 0);
|
||||
}
|
||||
|
||||
public static Fraction gcd(Fraction a, Fraction b) {
|
||||
if (a.compareTo(b) < 0) {
|
||||
Fraction t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
|
||||
if (a.isDivisibleBy(b)) {
|
||||
return b;
|
||||
}
|
||||
|
||||
return gcd(a.subtract(b), b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return a + " " + b;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (o == null || getClass() != o.getClass()) return false;
|
||||
|
||||
Fraction fraction = (Fraction) o;
|
||||
|
||||
if (a != fraction.a) return false;
|
||||
return b == fraction.b;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int result = (int) (a ^ a >>> 32);
|
||||
result = 31 * result + (int) (b ^ b >>> 32);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
public static BigInteger gcd(BigInteger a, BigInteger b) {
|
||||
if (a.equals(BigInteger.ZERO) || b.equals(BigInteger.ZERO)) {
|
||||
return a.max(b);
|
||||
}
|
||||
|
||||
while (!a.mod(b).equals(BigInteger.ZERO)) {
|
||||
a = a.mod(b);
|
||||
BigInteger t = a;
|
||||
a = b;
|
||||
b = t;
|
||||
}
|
||||
|
||||
return b;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
long M = 100;
|
||||
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
// System.out.println(new Fraction(((long) (Math.random() * M)), ((long) (Math.random() * M))));
|
||||
|
||||
|
||||
Fraction a = new Fraction(in.nextInt(), in.nextInt());
|
||||
Fraction b = new Fraction(in.nextInt(), in.nextInt());
|
||||
|
||||
// Fraction g = Fraction.gcd(a, b);
|
||||
//
|
||||
// Fraction ans1 = a.multiply(b).divide(g);
|
||||
// out.println(ans1);
|
||||
|
||||
BigInteger aa = BigInteger.valueOf(a.a);
|
||||
BigInteger ab = BigInteger.valueOf(a.b);
|
||||
BigInteger ba = BigInteger.valueOf(b.a);
|
||||
BigInteger bb = BigInteger.valueOf(b.b);
|
||||
|
||||
BigInteger bg = gcd(ab, bb);
|
||||
BigInteger b1 = ab.multiply(bb).divide(bg);
|
||||
BigInteger a1 = b1.divide(ab).multiply(aa);
|
||||
BigInteger a2 = b1.divide(bb).multiply(ba);
|
||||
BigInteger ag = gcd(a1, a2);
|
||||
BigInteger lcm = a1.multiply(a2).divide(ag);
|
||||
|
||||
BigInteger g = gcd(lcm, b1);
|
||||
BigInteger ar = lcm.divide(g);
|
||||
BigInteger br = b1.divide(g);
|
||||
|
||||
out.println(ar + " " + br);
|
||||
|
||||
// if (!ans1.equals(ans2)) {
|
||||
// throw new RuntimeException();
|
||||
// }
|
||||
}
|
||||
}
|
56
archive/2017.04/2017.04.16 - unsorted/TaskB.task
Normal file
56
archive/2017.04/2017.04.16 - unsorted/TaskB.task
Normal file
@@ -0,0 +1,56 @@
|
||||
5 TaskB
|
||||
12 MULTI_NUMBER
|
||||
8 STANDARD
|
||||
9 input.txt
|
||||
8 STANDARD
|
||||
10 output.txt
|
||||
4
|
||||
0
|
||||
21 2
|
||||
9 5 12 5
|
||||
1 10 3 100
|
||||
9 36 5
|
||||
3 10
|
||||
1
|
||||
1
|
||||
14 1
|
||||
1 100
|
||||
1 1000
|
||||
-1
|
||||
1
|
||||
2
|
||||
125 3
|
||||
38476513 2037278746
|
||||
553939120 1479775151
|
||||
78983548 165294827
|
||||
1855049790 771139337
|
||||
1386417042 1807485049
|
||||
492281701 1685084932
|
||||
-1
|
||||
1
|
||||
3
|
||||
45 4
|
||||
7 5
|
||||
13 16
|
||||
64 13
|
||||
86 13
|
||||
9 14
|
||||
2 13
|
||||
16 11
|
||||
52 75
|
||||
-1
|
||||
1
|
||||
11 src/chelper
|
||||
16 -Xmx256m -Xss64m
|
||||
4 Main
|
||||
13 chelper.TaskB
|
||||
39 net.egork.chelper.checkers.TokenChecker
|
||||
0
|
||||
0
|
||||
10 2017.04.16
|
||||
0
|
||||
1
|
||||
14 io.InputReader
|
||||
15 io.OutputWriter
|
||||
0
|
||||
0
|
124
archive/2017.04/2017.04.30 - unsorted/TaskA.java
Normal file
124
archive/2017.04/2017.04.30 - unsorted/TaskA.java
Normal file
@@ -0,0 +1,124 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
class Pancake implements Comparable<Pancake> {
|
||||
final int r;
|
||||
final int h;
|
||||
|
||||
public Pancake(int r, int h) {
|
||||
this.r = r;
|
||||
this.h = h;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Pancake o) {
|
||||
int t = -Integer.compare(r, o.r);
|
||||
if (t != 0) {
|
||||
return t;
|
||||
}
|
||||
return Integer.compare(h, o.h);
|
||||
}
|
||||
|
||||
double sides() {
|
||||
return 2 * Math.PI * r * h;
|
||||
}
|
||||
|
||||
double area() {
|
||||
return Math.PI * r * r;
|
||||
}
|
||||
|
||||
double total() {
|
||||
return sides() + area();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Pancake{" +
|
||||
"r=" + r +
|
||||
", h=" + h +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
int k = in.nextInt();
|
||||
|
||||
List<Pancake> pancakes = new ArrayList<>();
|
||||
|
||||
Random random = new Random();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
pancakes.add(new Pancake(in.nextInt(), in.nextInt()));
|
||||
|
||||
// pancakes.add(new Pancake(random.nextInt(100000), random.nextInt(100000)));
|
||||
}
|
||||
|
||||
Collections.sort(pancakes);
|
||||
|
||||
double[][] dp = new double[n + 1][n];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
dp[i][j] = -1;
|
||||
}
|
||||
}
|
||||
|
||||
// for (Pancake pancake : pancakes) {
|
||||
// System.out.println(pancake);
|
||||
// }
|
||||
|
||||
Arrays.fill(dp[0], 0);
|
||||
|
||||
for (int addI = 0; addI < n; addI++) {
|
||||
Pancake add = pancakes.get(addI);
|
||||
|
||||
double addTotal = add.total();
|
||||
double addArea = add.area();
|
||||
|
||||
for (int i = n - 1; i >= 0; i--) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
if (dp[i][j] < 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
double newRes = dp[i][j] + addTotal;
|
||||
if (i != 0) {
|
||||
newRes -= addArea;
|
||||
}
|
||||
|
||||
if (newRes > dp[i + 1][addI]) {
|
||||
// System.out.println("set " + (i + 1) + " " + j + " + " + addI + " = " + newRes);
|
||||
dp[i + 1][addI] = newRes;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
double max = -1;
|
||||
for (int i = 0; i < n; i++) {
|
||||
max = Math.max(max, dp[k][i]);
|
||||
}
|
||||
// System.out.println();
|
||||
|
||||
out.println(max);
|
||||
}
|
||||
}
|
15359
archive/2017.04/2017.04.30 - unsorted/TaskA.task
Normal file
15359
archive/2017.04/2017.04.30 - unsorted/TaskA.task
Normal file
File diff suppressed because it is too large
Load Diff
159
archive/2017.04/2017.04.30 - unsorted/TaskB.java
Normal file
159
archive/2017.04/2017.04.30 - unsorted/TaskB.java
Normal file
@@ -0,0 +1,159 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.GCJSolution;
|
||||
|
||||
|
||||
public class TaskB extends GCJSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
class Interval implements Comparable<Interval> {
|
||||
int start;
|
||||
int end;
|
||||
int kind;
|
||||
int len;
|
||||
|
||||
public Interval(int start, int end, int kind) {
|
||||
this.start = start;
|
||||
this.end = end;
|
||||
this.kind = kind;
|
||||
len = end - start;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Interval o) {
|
||||
return Integer.compare(start, o.start);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "Interval{" +
|
||||
"start=" + start +
|
||||
", end=" + end +
|
||||
", kind=" + kind +
|
||||
", len=" + len +
|
||||
'}';
|
||||
}
|
||||
}
|
||||
|
||||
int BIG = 1000000;
|
||||
|
||||
int[] makeDp() {
|
||||
int[] dp = new int[721];
|
||||
Arrays.fill(dp, BIG);
|
||||
return dp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
System.out.println("Test " + testNumber);
|
||||
System.out.flush();
|
||||
|
||||
List<Interval> intervals = new ArrayList<>();
|
||||
|
||||
int a1 = in.nextInt();
|
||||
int a2 = in.nextInt();
|
||||
|
||||
for (int i = 0; i < a1; i++) {
|
||||
intervals.add(new Interval(in.nextInt(), in.nextInt(), 0));
|
||||
}
|
||||
for (int i = 0; i < a2; i++) {
|
||||
intervals.add(new Interval(in.nextInt(), in.nextInt(), 1));
|
||||
}
|
||||
|
||||
int[] dp = makeDp();
|
||||
int[] newDp;
|
||||
|
||||
dp[0] = 0;
|
||||
|
||||
Collections.sort(intervals);
|
||||
|
||||
intervals.add(new Interval(intervals.get(0).start + 1440, intervals.get(0).end + 1440, intervals.get(0).kind));
|
||||
|
||||
int totalTaken = 0;
|
||||
|
||||
for (int intervalI = 0; intervalI < intervals.size() - 1; intervalI++) {
|
||||
Interval x = intervals.get(intervalI);
|
||||
int k = x.kind;
|
||||
|
||||
{
|
||||
newDp = makeDp();
|
||||
for (int aTaken = 0; aTaken <= 720; aTaken++) {
|
||||
int bTaken = totalTaken - aTaken;
|
||||
|
||||
if (bTaken < 0 || dp[aTaken] == BIG) {
|
||||
continue;
|
||||
}
|
||||
|
||||
int aTaken2 = aTaken + (k == 0 ? x.len : 0);
|
||||
int bTaken2 = bTaken + (k == 1 ? x.len : 0);
|
||||
|
||||
if (aTaken2 > 720 || bTaken2 > 720) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newDp[aTaken2] = dp[aTaken];
|
||||
}
|
||||
totalTaken += x.len;
|
||||
dp = newDp;
|
||||
}
|
||||
|
||||
Interval next = intervals.get(intervalI + 1);
|
||||
int k2 = next.kind;
|
||||
int dist = next.start - x.end;
|
||||
|
||||
{
|
||||
newDp = makeDp();
|
||||
for (int aTaken = 0; aTaken <= 720; aTaken++) {
|
||||
int bTaken = totalTaken - aTaken;
|
||||
if (bTaken < 0 || dp[aTaken] == BIG) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (int aAdd = 0; aAdd <= dist; aAdd++) {
|
||||
int bAdd = dist - aAdd;
|
||||
|
||||
int penalty = 0;
|
||||
|
||||
if (k != k2) {
|
||||
penalty = 1;
|
||||
} else {
|
||||
if (k == 0 && bAdd > 0) {
|
||||
penalty = 2;
|
||||
}
|
||||
if (k == 1 && aAdd > 0) {
|
||||
penalty = 2;
|
||||
}
|
||||
}
|
||||
|
||||
int aTaken2 = aTaken + aAdd;
|
||||
int bTaken2 = bTaken + bAdd;
|
||||
|
||||
if (aTaken2 > 720 || bTaken2 > 720) {
|
||||
continue;
|
||||
}
|
||||
|
||||
newDp[aTaken2] = Math.min(newDp[aTaken2], dp[aTaken] + penalty);
|
||||
}
|
||||
}
|
||||
totalTaken += dist;
|
||||
dp = newDp;
|
||||
}
|
||||
}
|
||||
|
||||
int ans = BIG;
|
||||
for (int i = 0; i <= 720; i++) {
|
||||
ans = Math.min(ans, dp[i]);
|
||||
}
|
||||
out.println(ans);
|
||||
}
|
||||
}
|
8834
archive/2017.04/2017.04.30 - unsorted/TaskB.task
Normal file
8834
archive/2017.04/2017.04.30 - unsorted/TaskB.task
Normal file
File diff suppressed because it is too large
Load Diff
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user