git reimport
This commit is contained in:
231
archive/2019.02/2019.02.21 - unsorted/D.java
Normal file
231
archive/2019.02/2019.02.21 - unsorted/D.java
Normal file
@@ -0,0 +1,231 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Random;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SimpleSavingChelperSolution;
|
||||
|
||||
|
||||
public class D extends SimpleSavingChelperSolution {
|
||||
|
||||
public static final int N = 100000;
|
||||
public static final int TOTAL_TURNS = 100;
|
||||
public static final int PREP_TURNS = 45;
|
||||
|
||||
static class Solver {
|
||||
List<Integer> history = new ArrayList<>();
|
||||
int minIndex = -1;
|
||||
int turn = 0;
|
||||
|
||||
String decide(String s) {
|
||||
int x = -1;
|
||||
if (s != null) {
|
||||
x = strToInt(s);
|
||||
}
|
||||
|
||||
int ans = decide(x, turn);
|
||||
turn++;
|
||||
return intToStr(ans);
|
||||
}
|
||||
|
||||
int decide(int x, int turn) {
|
||||
if (turn == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
history.add(x);
|
||||
|
||||
if (turn < PREP_TURNS) {
|
||||
return x;
|
||||
}
|
||||
|
||||
if (turn == PREP_TURNS) {
|
||||
findMinIndex();
|
||||
System.err.println("GUESS:");
|
||||
System.err.println("max: " + intToStr(history.get(minIndex - 1)));
|
||||
System.err.println("min: " + intToStr(history.get(minIndex)));
|
||||
}
|
||||
|
||||
int maxValue = history.get(minIndex - 1);
|
||||
int minValue = history.get(minIndex);
|
||||
int randValue = history.get(minIndex + 1);
|
||||
|
||||
if (x == maxValue) {
|
||||
return minValue;
|
||||
}
|
||||
if (x == minValue) {
|
||||
return randValue;
|
||||
}
|
||||
return maxValue;
|
||||
}
|
||||
|
||||
void findMinIndex() {
|
||||
for (int i = 1; i < history.size() - 1; i++) {
|
||||
for (int j = i + 1; j < history.size() - 1; j++) {
|
||||
for (int k = j + 1; k < history.size() - 1; k++) {
|
||||
int a1 = history.get(i - 1);
|
||||
int a2 = history.get(i);
|
||||
int a3 = history.get(i + 1);
|
||||
int b1 = history.get(j - 1);
|
||||
int b2 = history.get(j);
|
||||
int b3 = history.get(j + 1);
|
||||
int c1 = history.get(k - 1);
|
||||
int c2 = history.get(k);
|
||||
int c3 = history.get(k + 1);
|
||||
|
||||
if (a1 == b1 && b1 == c1
|
||||
&& a2 == b2 && b2 == c2
|
||||
&& a1 != a2
|
||||
&& a3 != b3 && a3 != c3 && b3 != c3
|
||||
) {
|
||||
minIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i < history.size() - 1; i++) {
|
||||
for (int j = i + 1; j < history.size() - 1; j++) {
|
||||
int a1 = history.get(i - 1);
|
||||
int a2 = history.get(i);
|
||||
int a3 = history.get(i + 1);
|
||||
int b1 = history.get(j - 1);
|
||||
int b2 = history.get(j);
|
||||
int b3 = history.get(j + 1);
|
||||
|
||||
if (a1 == b1
|
||||
&& a2 == b2
|
||||
&& a1 != a2
|
||||
&& a3 != b3
|
||||
) {
|
||||
minIndex = i;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
throw new IllegalArgumentException(":(");
|
||||
}
|
||||
}
|
||||
|
||||
static class Checker {
|
||||
List<String> bank = new ArrayList<>();
|
||||
Map<String, Integer> bankPos = new HashMap<>();
|
||||
Random random = new Random();
|
||||
|
||||
Checker() {
|
||||
for (int i = 0; i < N; i++) {
|
||||
bank.add(intToStr(i));
|
||||
}
|
||||
Collections.shuffle(bank, random);
|
||||
|
||||
for (int i = 0; i < N; i++) {
|
||||
bankPos.put(bank.get(i), i);
|
||||
}
|
||||
}
|
||||
|
||||
boolean greater(String a, String b) {
|
||||
if (a.equals(bank.get(0)) && b.equals(bank.get(N - 1))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return bankPos.get(a) > bankPos.get(b);
|
||||
}
|
||||
|
||||
String decide(String s) {
|
||||
int x = bankPos.get(s);
|
||||
|
||||
if (x == N - 1) {
|
||||
return bank.get(0);
|
||||
}
|
||||
|
||||
if (x == 0) {
|
||||
return bank.get(x + 1 + random.nextInt(N - x - 2));
|
||||
}
|
||||
|
||||
return bank.get(x + 1 + random.nextInt(N - x - 1));
|
||||
}
|
||||
|
||||
int run() {
|
||||
Solver solver = new Solver();
|
||||
int score = 0;
|
||||
|
||||
String prev = null;
|
||||
for (int i = 0; i <= TOTAL_TURNS; i++) {
|
||||
String attempt = solver.decide(prev);
|
||||
|
||||
if (prev != null && greater(attempt, prev)) {
|
||||
score++;
|
||||
}
|
||||
|
||||
prev = decide(attempt);
|
||||
|
||||
if (!greater(prev, attempt)) {
|
||||
System.err.println("WAHT");
|
||||
}
|
||||
}
|
||||
|
||||
return score;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
public void solve(int testNumber) {
|
||||
int T = in.nextInt();
|
||||
int N = in.nextInt();
|
||||
|
||||
for (int i = 0; i < T; i++) {
|
||||
solveTestCase();
|
||||
}
|
||||
}
|
||||
|
||||
static int strToInt(String s) {
|
||||
int result = 0;
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
result *= 10;
|
||||
result += s.charAt(i) - 'A';
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static String intToStr(int x) {
|
||||
String result = "";
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
result = (char) (x % 10 + 'A') + result;
|
||||
x /= 10;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
private void solveTestCase() {
|
||||
// Checker checker = new Checker();
|
||||
// System.err.println(checker.run());
|
||||
|
||||
Solver solver = new Solver();
|
||||
String prev = null;
|
||||
for (int i = 0; i <= TOTAL_TURNS; i++) {
|
||||
String answer = solver.decide(prev);
|
||||
System.out.println(answer);
|
||||
System.out.flush();
|
||||
|
||||
if (i < TOTAL_TURNS) {
|
||||
prev = in.nextString();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
33
archive/2019.02/2019.02.21 - unsorted/D.json
Normal file
33
archive/2019.02/2019.02.21 - unsorted/D.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name" : "D",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "1 5",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.D",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.21",
|
||||
"contestName" : "",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
43
archive/2019.02/2019.02.24 - KickstartPrep/TaskA.java
Normal file
43
archive/2019.02/2019.02.24 - KickstartPrep/TaskA.java
Normal file
@@ -0,0 +1,43 @@
|
||||
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 testCount = in.nextInt();
|
||||
|
||||
for (int test = 0; test < testCount; test++) {
|
||||
int a = in.nextInt();
|
||||
int b = in.nextInt();
|
||||
int n = in.nextInt();
|
||||
|
||||
while (true) {
|
||||
int m = (a + b + 1) / 2;
|
||||
|
||||
out.println(m);
|
||||
out.flush();
|
||||
|
||||
String resp = in.nextString();
|
||||
|
||||
if (resp.equals("CORRECT")) {
|
||||
break;
|
||||
} else if (resp.equals("TOO_BIG")) {
|
||||
b = m - 1;
|
||||
} else if (resp.equals("TOO_SMALL")) {
|
||||
a = m + 1;
|
||||
} else {
|
||||
System.out.println("WTF");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
33
archive/2019.02/2019.02.24 - KickstartPrep/TaskA.json
Normal file
33
archive/2019.02/2019.02.24 - KickstartPrep/TaskA.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name" : "TaskA",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "1\n12",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskA",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.24",
|
||||
"contestName" : "KickstartPrep",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : true,
|
||||
"interactor" : "chelper.TaskAInteractor"
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
package chelper;
|
||||
|
||||
import net.egork.chelper.tester.State;
|
||||
import net.egork.chelper.tester.Verdict;
|
||||
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
|
||||
public class TaskAInteractor {
|
||||
public Verdict interact(InputStream rawTestInput, InputStream rawIn, OutputStream rawOut, State<Boolean> state) {
|
||||
InputReader testIn = new InputReader(rawTestInput);
|
||||
InputReader in = new InputReader(rawIn);
|
||||
OutputWriter out = new OutputWriter(rawOut);
|
||||
|
||||
int testCount = testIn.nextInt();
|
||||
out.println(testCount);
|
||||
|
||||
int a = 0;
|
||||
int b = 1000;
|
||||
int n = 30;
|
||||
|
||||
for (int test = 1; test <= testCount; test++) {
|
||||
int x = testIn.nextInt();
|
||||
|
||||
out.println(a + " " + b);
|
||||
out.println(n);
|
||||
|
||||
for (int guessCount = 0; true; guessCount++) {
|
||||
if (guessCount >= n) {
|
||||
return Verdict.WA;
|
||||
}
|
||||
|
||||
int guess = in.nextInt();
|
||||
|
||||
if (guess == x) {
|
||||
out.println("CORRECT");
|
||||
break;
|
||||
}
|
||||
|
||||
if (guess < x) {
|
||||
out.println("TOO_SMALL");
|
||||
} else {
|
||||
out.println("TOO_BIG");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Verdict.OK;
|
||||
}
|
||||
}
|
44
archive/2019.02/2019.02.24 - KickstartPrep/TaskB.java
Normal file
44
archive/2019.02/2019.02.24 - KickstartPrep/TaskB.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import misc.SavingChelperSolution;
|
||||
|
||||
|
||||
public class TaskB extends SavingChelperSolution {
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
wrapSolve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
out.printf("Case #%d: ", testNumber);
|
||||
|
||||
int n = in.nextInt();
|
||||
|
||||
String s = in.nextString();
|
||||
|
||||
int[] a = new int[n];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i] = s.charAt(i) - '0';
|
||||
}
|
||||
|
||||
int k = (n + 1) / 2;
|
||||
|
||||
int sum = 0;
|
||||
|
||||
for (int i = 0; i < k; i++) {
|
||||
sum += a[i];
|
||||
}
|
||||
int max = sum;
|
||||
|
||||
for (int i = k; i < n; i++) {
|
||||
sum += a[i] - a[i - k];
|
||||
max = Math.max(max, sum);
|
||||
}
|
||||
|
||||
out.println(max);
|
||||
}
|
||||
}
|
34
archive/2019.02/2019.02.24 - KickstartPrep/TaskB.json
Normal file
34
archive/2019.02/2019.02.24 - KickstartPrep/TaskB.json
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
"name" : "TaskB",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "4\n4\n1332\n4\n9583\n3\n616\n10\n1029384756",
|
||||
"output" : "Case #1: 6\nCase #2: 14\nCase #3: 7\nCase #4: 31",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskB",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.24",
|
||||
"contestName" : "KickstartPrep",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
97
archive/2019.02/2019.02.26 - GCJPrep/TaskC.java
Normal file
97
archive/2019.02/2019.02.26 - GCJPrep/TaskC.java
Normal file
@@ -0,0 +1,97 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import prep.LongMod;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskC extends ChelperSolution {
|
||||
|
||||
{
|
||||
gcj = true;
|
||||
}
|
||||
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
final LongMod MOD = new LongMod(1000000007L);
|
||||
|
||||
int N = 1001000;
|
||||
long[] inverses = new long[N];
|
||||
|
||||
@Override
|
||||
protected void precalc() {
|
||||
for (int i = 2; i < N; i++) {
|
||||
inverses[i] = MOD.inversePrime(i - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
int k = in.nextInt();
|
||||
|
||||
long x1 = in.nextInt();
|
||||
long y1 = in.nextInt();
|
||||
long C = in.nextInt();
|
||||
long D = in.nextInt();
|
||||
long E1 = in.nextInt();
|
||||
long E2 = in.nextInt();
|
||||
long FVal = in.nextInt();
|
||||
|
||||
LongMod F = new LongMod(FVal);
|
||||
|
||||
long[] x = new long[n];
|
||||
long[] y = new long[n];
|
||||
|
||||
x[0] = F.mod(x1);
|
||||
y[0] = F.mod(y1);
|
||||
|
||||
for (int i = 1; i < n; i++) {
|
||||
x[i] = F.sum(
|
||||
F.prod(x[i - 1], C),
|
||||
F.prod(y[i - 1], D),
|
||||
E1
|
||||
);
|
||||
y[i] = F.sum(
|
||||
F.prod(x[i - 1], D),
|
||||
F.prod(y[i - 1], C),
|
||||
E2
|
||||
);
|
||||
}
|
||||
|
||||
long[] a = new long[n];
|
||||
for (int i = 0; i < n; i++) {
|
||||
a[i] = F.sum(x[i], y[i]);
|
||||
}
|
||||
|
||||
long[] numPowers = new long[n + 1];
|
||||
numPowers[1] = MOD.mod(k);
|
||||
for (int i = 2; i <= n; i++) {
|
||||
numPowers[i] = MOD.prod(
|
||||
i,
|
||||
MOD.sub(MOD.pow(i, k), 1),
|
||||
inverses[i]
|
||||
);
|
||||
}
|
||||
|
||||
long res = 0;
|
||||
long numSum = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
numSum = MOD.sum(numSum, numPowers[i + 1]);
|
||||
res = MOD.sum(
|
||||
res,
|
||||
MOD.prod(
|
||||
a[i],
|
||||
n - i,
|
||||
numSum
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
debug.println("hi");
|
||||
out.println(res);
|
||||
}
|
||||
}
|
42
archive/2019.02/2019.02.26 - GCJPrep/TaskC.json
Normal file
42
archive/2019.02/2019.02.26 - GCJPrep/TaskC.json
Normal file
@@ -0,0 +1,42 @@
|
||||
{
|
||||
"name" : "TaskC",
|
||||
"testType" : "MULTI_NUMBER",
|
||||
"input" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "input.txt"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD",
|
||||
"fileName" : "output.txt"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "2\n2 3 1 2 1 2 1 1 9\n10 10 10001 10002 10003 10004 10005 10006 89273\n",
|
||||
"output" : "Case #1: 52\nCase #2: 739786670\n",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "2\n2 1 1 2 1 2 1 1 9\n10 1 10001 10002 10003 10004 10005 10006 89273\n",
|
||||
"index" : 1,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "10\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n1000000 1000 1 2 1 2 1 1 9\n",
|
||||
"index" : 2,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256m -Xss64m",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskC",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.26",
|
||||
"contestName" : "GCJPrep",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false,
|
||||
"interactor" : "net.egork.chelper.tester.Interactor"
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name" : "A - Gennady and a Card Game",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "AS\n2H 4C TH JH AD",
|
||||
"output" : "YES",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "2H\n3D 4C AC KD AS\n",
|
||||
"output" : "NO",
|
||||
"index" : 1,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "4D\nAS AC AD AH 5H\n",
|
||||
"output" : "YES",
|
||||
"index" : 2,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256M",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskA",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.27",
|
||||
"contestName" : "Hello 2019",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name" : "B - Petr and a Combination Lock",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "3\n10\n20\n30\n",
|
||||
"output" : "YES",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "3\n10\n10\n10\n",
|
||||
"output" : "NO",
|
||||
"index" : 1,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "3\n120\n120\n120\n",
|
||||
"output" : "YES",
|
||||
"index" : 2,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256M",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskB",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.27",
|
||||
"contestName" : "Hello 2019",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false
|
||||
}
|
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name" : "C - Yuhao and a Parenthesis",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "7\n)())\n)\n((\n((\n(\n)\n)\n",
|
||||
"output" : "2",
|
||||
"index" : 0,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "4\n(\n((\n(((\n(())\n",
|
||||
"output" : "0",
|
||||
"index" : 1,
|
||||
"active" : true
|
||||
}, {
|
||||
"input" : "2\n(())\n()\n",
|
||||
"output" : "1",
|
||||
"index" : 2,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256M",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskC",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.27",
|
||||
"contestName" : "Hello 2019",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false
|
||||
}
|
@@ -0,0 +1,45 @@
|
||||
{
|
||||
"name" : "D - Makoto and a Blackboard",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"tests" : [ {
|
||||
"input" : "6 1",
|
||||
"output" : "3",
|
||||
"index" : 0,
|
||||
"active" : false
|
||||
}, {
|
||||
"input" : "6 2",
|
||||
"output" : "875000008\n",
|
||||
"index" : 1,
|
||||
"active" : false
|
||||
}, {
|
||||
"input" : "60 5",
|
||||
"output" : "237178099\n",
|
||||
"index" : 2,
|
||||
"active" : false
|
||||
}, {
|
||||
"input" : "978217616376000 1",
|
||||
"index" : 3,
|
||||
"active" : true
|
||||
} ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256M",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskD",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.27",
|
||||
"contestName" : "Hello 2019",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name" : "E - Egor and an RPG game",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"tests" : [ ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256M",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskE",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.27",
|
||||
"contestName" : "Hello 2019",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name" : "F - Alex and a TV Show",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"tests" : [ ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx256M",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskF",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.27",
|
||||
"contestName" : "Hello 2019",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name" : "G - Vladislav and a Great Legend",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"tests" : [ ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx512M",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskG",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.27",
|
||||
"contestName" : "Hello 2019",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false
|
||||
}
|
@@ -0,0 +1,26 @@
|
||||
{
|
||||
"name" : "H - Mateusz and an Infinite Sequence",
|
||||
"testType" : "SINGLE",
|
||||
"input" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"output" : {
|
||||
"type" : "STANDARD"
|
||||
},
|
||||
"tests" : [ ],
|
||||
"location" : "src/chelper",
|
||||
"vmArgs" : "-Xmx512M",
|
||||
"mainClass" : "Main",
|
||||
"taskClass" : "chelper.TaskH",
|
||||
"checkerClass" : "net.egork.chelper.checkers.TokenChecker",
|
||||
"checkerParameters" : "",
|
||||
"testClasses" : [ ],
|
||||
"date" : "2019.02.27",
|
||||
"contestName" : "Hello 2019",
|
||||
"truncate" : true,
|
||||
"inputClass" : "io.InputReader",
|
||||
"outputClass" : "io.OutputWriter",
|
||||
"includeLocale" : false,
|
||||
"failOnOverflow" : false,
|
||||
"interactive" : false
|
||||
}
|
29
archive/2019.02/2019.02.27 - Hello 2019/TaskA.java
Normal file
29
archive/2019.02/2019.02.27 - Hello 2019/TaskA.java
Normal file
@@ -0,0 +1,29 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskA extends ChelperSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
String hand = in.nextString();
|
||||
|
||||
boolean ok = false;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
String s = in.nextString();
|
||||
|
||||
ok |= s.charAt(0) == hand.charAt(0);
|
||||
ok |= s.charAt(1) == hand.charAt(1);
|
||||
}
|
||||
|
||||
out.println(ok ? "YES" : "NO");
|
||||
}
|
||||
}
|
41
archive/2019.02/2019.02.27 - Hello 2019/TaskB.java
Normal file
41
archive/2019.02/2019.02.27 - Hello 2019/TaskB.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskB extends ChelperSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
|
||||
int[] a = in.nextIntArray(n);
|
||||
|
||||
boolean ok = false;
|
||||
|
||||
for (int mask = 0; mask < 1 << n; mask++) {
|
||||
int res = 0;
|
||||
int t = mask;
|
||||
for (int i = 0; i < n; i++) {
|
||||
if ((t & 1) == 0) {
|
||||
res += a[i];
|
||||
} else {
|
||||
res -= a[i];
|
||||
}
|
||||
t /= 2;
|
||||
}
|
||||
|
||||
res = (res % 360 + 360) % 360;
|
||||
ok |= res == 0;
|
||||
}
|
||||
|
||||
out.println(ok ? "YES" : "NO");
|
||||
}
|
||||
}
|
58
archive/2019.02/2019.02.27 - Hello 2019/TaskC.java
Normal file
58
archive/2019.02/2019.02.27 - Hello 2019/TaskC.java
Normal file
@@ -0,0 +1,58 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskC extends ChelperSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
int n = in.nextInt();
|
||||
|
||||
int equals = 0;
|
||||
Map<Integer, Integer> counts = new HashMap<>();
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
String s = in.nextString();
|
||||
|
||||
int balance = 0;
|
||||
int min = 0;
|
||||
for (char c : s.toCharArray()) {
|
||||
if (c == '(') {
|
||||
balance++;
|
||||
} else {
|
||||
balance--;
|
||||
}
|
||||
min = Math.min(min, balance);
|
||||
}
|
||||
|
||||
if (min == 0 && balance == 0) {
|
||||
equals++;
|
||||
continue;
|
||||
}
|
||||
|
||||
if ((min == 0 && balance > 0) || (min < 0 && balance == min)) {
|
||||
counts.put(balance, 1 + counts.getOrDefault(balance, 0));
|
||||
}
|
||||
}
|
||||
|
||||
int res = equals / 2;
|
||||
for (Map.Entry<Integer, Integer> entry : counts.entrySet()) {
|
||||
if (entry.getKey() > 0) {
|
||||
res += Math.min(entry.getValue(), counts.getOrDefault(-entry.getKey(), 0));
|
||||
}
|
||||
}
|
||||
|
||||
out.println(res);
|
||||
}
|
||||
}
|
77
archive/2019.02/2019.02.27 - Hello 2019/TaskD.java
Normal file
77
archive/2019.02/2019.02.27 - Hello 2019/TaskD.java
Normal file
@@ -0,0 +1,77 @@
|
||||
package chelper;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import prep.Algo;
|
||||
import prep.LongMod;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskD extends ChelperSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
LongMod mod = new LongMod(1_000_000_007L);
|
||||
|
||||
long[][] matmul(long[][] a, long[][] b) {
|
||||
int n = a.length;
|
||||
|
||||
long[][] c = new long[n][n];
|
||||
|
||||
for (int i = 0; i < n; i++) {
|
||||
for (int j = 0; j < n; j++) {
|
||||
for (int k = 0; k < n; k++) {
|
||||
c[i][j] = mod.sum(
|
||||
c[i][j],
|
||||
mod.prod(a[i][k], b[k][j])
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
long[][] matpow(long[][] a, int b) {
|
||||
if (b == 1) {
|
||||
return a;
|
||||
}
|
||||
|
||||
if (b % 2 == 0) {
|
||||
long[][] c = matpow(a, b / 2);
|
||||
return matmul(c, c);
|
||||
} else {
|
||||
return matmul(
|
||||
a,
|
||||
matpow(a, b - 1)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// public long solvePrime(long prime, int power, int k) {
|
||||
//
|
||||
// }
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
long n = in.nextLong();
|
||||
int k = in.nextInt();
|
||||
|
||||
Map<Long, Integer> factorization = Algo.dumbFactorize(n);
|
||||
|
||||
long answer = 1;
|
||||
|
||||
for (Map.Entry<Long, Integer> entry : factorization.entrySet()) {
|
||||
long prime = entry.getKey();
|
||||
int power = entry.getValue();
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
19
archive/2019.02/2019.02.27 - Hello 2019/TaskE.java
Normal file
19
archive/2019.02/2019.02.27 - Hello 2019/TaskE.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskE extends ChelperSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
|
||||
}
|
||||
}
|
19
archive/2019.02/2019.02.27 - Hello 2019/TaskF.java
Normal file
19
archive/2019.02/2019.02.27 - Hello 2019/TaskF.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskF extends ChelperSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
|
||||
}
|
||||
}
|
19
archive/2019.02/2019.02.27 - Hello 2019/TaskG.java
Normal file
19
archive/2019.02/2019.02.27 - Hello 2019/TaskG.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskG extends ChelperSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
|
||||
}
|
||||
}
|
19
archive/2019.02/2019.02.27 - Hello 2019/TaskH.java
Normal file
19
archive/2019.02/2019.02.27 - Hello 2019/TaskH.java
Normal file
@@ -0,0 +1,19 @@
|
||||
package chelper;
|
||||
|
||||
import io.InputReader;
|
||||
import io.OutputWriter;
|
||||
import solutions.ChelperSolution;
|
||||
|
||||
|
||||
public class TaskH extends ChelperSolution {
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber, InputReader in, OutputWriter out) {
|
||||
super.solve(testNumber, in, out);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void solve(int testNumber) {
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user