git reimport
This commit is contained in:
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
|
Reference in New Issue
Block a user