git reimport

This commit is contained in:
2019-03-15 13:47:54 +04:00
commit 3b461f73de
489 changed files with 1631603 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
package chelper;
import static misc.Stuff.min;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class A 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() - 1;
int a = in.nextInt();
int b = in.nextInt();
int c = in.nextInt();
long ans = min(a * n, b * n);
if (n >= 1) {
ans = min(ans, a + c * (n - 1), b + c * (n - 1));
}
out.println(ans);
}
}

View File

@@ -0,0 +1,35 @@
1 A
6 SINGLE
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
2
0
7 3
2
3
1
1 3
1
1
7 1
2
3
5
1 0
1
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
9 chelper.A
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2017.10.16
0
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,48 @@
package chelper;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class B 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 k = in.nextInt();
int m = in.nextInt();
int[] a = in.nextIntArray(n);
int[] mods = new int[m];
boolean ok = false;
int goodMod = -1;
for (int i : a) {
mods[i % m]++;
if (mods[i % m] >= k) {
ok = true;
goodMod = i % m;
}
}
if (!ok) {
out.println("No");
return;
}
out.println("Yes");
for (int i : a) {
if (i % m == goodMod && k > 0) {
k--;
out.print(i + " ");
}
}
}
}

View File

@@ -0,0 +1,38 @@
1 B
6 SINGLE
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
3
0
11 3 2 3
1 8 4
8 Yes
1 4
1
1
11 3 3 3
1 8 4
2 No
1
2
13 4 3 5
2 7 7 7
10 Yes
2 7 7
1
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
9 chelper.B
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2017.10.16
0
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,44 @@
package chelper;
import java.util.ArrayList;
import java.util.List;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class C extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
int sum(int x) {
int res = 0;
while (x > 0) {
res += x % 10;
x /= 10;
}
return res;
}
@Override
public void solve(int testNumber) {
int n = in.nextInt();
List<Integer> ans = new ArrayList<>();
for (int i = Math.max(0, n - 1000); i < n; i++) {
if (i + sum(i) == n) {
ans.add(i);
}
}
out.println(ans.size());
for (int i : ans) {
out.println(i);
}
}
}

View File

@@ -0,0 +1,30 @@
1 C
6 SINGLE
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
2
0
2 21
4 1
15
1
1
2 20
1 0
1
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
9 chelper.C
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2017.10.16
0
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,91 @@
package chelper;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class D extends SimpleSavingChelperSolution {
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
class Node {
int l, r, m;
int sum;
Node cl, cr;
Node(int l, int r) {
this.l = l;
this.r = r;
m = (l + r) / 2;
sum = 0;
if (r - l > 1) {
cl = new Node(l, m);
cr = new Node(m, r);
}
}
void add(int x) {
sum++;
if (r - l > 1) {
if (x < m) {
cl.add(x);
} else {
cr.add(x);
}
}
}
int sum(int ll, int rr) {
if (ll == l && rr == r) {
return sum;
}
int ans = 0;
if (ll < m) {
ans += cl.sum(ll, Math.min(m, rr));
}
if (rr > m) {
ans += cr.sum(Math.max(m, ll), rr);
}
return ans;
}
}
@Override
public void solve(int testNumber) {
int n = in.nextInt();
out.print(1 + " ");
Node root = new Node(0, n);
for (int totalSum = 1; totalSum <= n; totalSum++) {
root.add(in.nextInt() - 1);
int l = 0;
int r = n + 1;
while (r - l > 1) {
int m = (l + r) / 2;
int x = root.sum(n - m, n);
if (x == m) {
l = m;
} else {
r = m;
}
}
out.print((totalSum - l + 1) + " ");
// out.println(root.sum(0, n));
}
}
}

View File

@@ -0,0 +1,31 @@
1 D
6 SINGLE
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
2
0
9 4
1 3 4 2
9 1 2 3 2 1
1
1
17 8
6 8 3 4 7 2 1 5
17 1 2 2 3 4 3 4 5 1
1
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
9 chelper.D
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2017.10.16
0
1
14 io.InputReader
15 io.OutputWriter
0
0

View File

@@ -0,0 +1,156 @@
package chelper;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import io.InputReader;
import io.OutputWriter;
import misc.SimpleSavingChelperSolution;
public class E extends SimpleSavingChelperSolution {
private int n;
private int k;
private int m;
private int[] a;
private int[] length;
private int[] pos;
private int[] next;
private boolean[] fixed;
private boolean[] changed;
private int first;
private boolean[] same;
public void solve(int testNumber, InputReader in, OutputWriter out) {
wrapSolve(testNumber, in, out);
}
@Override
public void solve(int testNumber) {
n = in.nextInt();
k = in.nextInt();
m = 100100;
a = new int[m];
length = new int[n];
pos = new int[n];
int t = 0;
next = new int[n];
for (int i = 0; i < n; i++) {
length[i] = in.nextInt();
pos[i] = t;
for (int j = 0; j < length[i]; j++) {
a[t++] = in.nextInt() - 1;
}
next[i] = i + 1;
}
fixed = new boolean[k];
changed = new boolean[k];
first = 0;
same = new boolean[n];
Arrays.fill(same, true);
if (stuff()) {
return;
}
Arrays.fill(same, true);
for (int i = 0; i < n; i++) {
next[i] = i + 1;
}
first = 0;
if (stuff()) {
return;
}
List<Integer> ans = new ArrayList<>();
for (int i = 0; i < k; i++) {
if (changed[i]) {
ans.add(i);
}
}
out.println("Yes");
out.println(ans.size());
for (int i : ans) {
out.print((i + 1) + " ");
}
}
private boolean stuff() {
for (int i = 0; i < m; i++) {
for (int p1 = first; p1 < n; p1 = next[p1]) {
int p2 = next[p1];
if (p2 >= n) {
break;
}
if (!same[p1]) {
continue;
}
int o1 = a[pos[p1] + i];
int l1 = changed[o1] ? o1 - k : o1;
int o2 = a[pos[p2] + i];
int l2 = changed[o2] ? o2 - k : o2;
if (l1 < l2) {
same[p1] = false;
continue;
}
if (l1 == l2) {
if (length[p1] > i + 1 && length[p2] == i + 1) {
out.println("No");
return true;
}
}
if (l1 > l2) {
same[p1] = false;
if (o1 < o2) {
if (fixed[o1]) {
out.println("No");
return true;
}
fixed[o1] = true;
changed[o1] = true;
}
if (o1 > o2) {
if ((!changed[o1] && fixed[o1]) || (changed[o2] && fixed[o2])) {
out.println("No");
return true;
}
changed[o1] = true;
changed[o2] = false;
fixed[o1] = true;
fixed[o2] = true;
}
}
}
while (first < n && length[first] - 1 == i) {
first = next[first];
}
for (int j = first; j < n; j = next[j]) {
while (next[j] < n && length[next[j]] - 1 == i) {
same[j] = false;
next[j] = next[next[j]];
}
}
}
return false;
}
}

View File

@@ -0,0 +1,158 @@
1 E
6 SINGLE
8 STANDARD
9 input.txt
8 STANDARD
10 output.txt
17
0
25 4 3
1 2
1 1
3 1 3 2
2 1 1
10 Yes
2
2 3
1
1
41 6 5
2 1 2
2 1 2
3 1 2 3
2 1 5
2 4 4
2 4 4
5 Yes
0
1
2
35 4 3
4 3 2 2 1
3 1 1 3
3 2 3 3
2 3 1
2 No
1
3
19 2 2
3 2 1 1
3 1 1 1
7 Yes
1
2
1
4
15 2 2
1 2
3 1 1 1
7 Yes
1
2
1
5
19 2 2
3 2 1 2
3 2 2 2
5 Yes
0
1
6
25 3 4
2 2 4
3 2 3 2
3 2 2 2
2 No
1
7
15 3 3
1 3
1 2
1 1
2 No
1
8
21 3 1
3 1 1 1
2 1 1
1 1
2 No
1
9
13 2 1
2 1 1
1 1
2 No
1
10
25 3 2
3 1 1 1
2 2 1
3 2 1 1
5 Yes
0
1
11
19 3 2
1 1
2 1 2
2 1 1
7 Yes
1
2
1
12
25 3 2
2 1 1
3 1 1 2
3 1 1 1
7 Yes
1
2
1
13
31 3 2
3 1 1 1
4 1 1 1 2
4 1 1 1 1
7 Yes
1
2
1
14
19 3 2
1 1
2 2 2
2 2 1
2 No
1
15
19 4 4
1 2
1 1
1 4
1 3
-1
1
16
13 2 3
2 3 2
1 2
7 Yes
1
3
1
11 src/chelper
16 -Xmx256m -Xss64m
4 Main
9 chelper.E
39 net.egork.chelper.checkers.TokenChecker
0
0
10 2017.10.16
0
1
14 io.InputReader
15 io.OutputWriter
0
0