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