Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f6d75db8b6 |
Generated
-1
@@ -1,6 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="GradleMigrationSettings" migrationVersion="1" />
|
|
||||||
<component name="GradleSettings">
|
<component name="GradleSettings">
|
||||||
<option name="linkedExternalProjectsSettings">
|
<option name="linkedExternalProjectsSettings">
|
||||||
<GradleProjectSettings>
|
<GradleProjectSettings>
|
||||||
|
|||||||
@@ -0,0 +1,3 @@
|
|||||||
|
# NCPC
|
||||||
|
|
||||||
|
Hi, this is my journy thru out NCPC, check the forks for the year you are intrested to check.
|
||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.kattis.ncpc25.log.rider;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
public class A {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
int[] nums = getComponents(Integer.parseInt(in.readLine()));
|
||||||
|
System.out.println(nums[0] + " " + nums[1]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int[] getComponents(int input)
|
||||||
|
{
|
||||||
|
int num = new Random().nextInt(-999, 1000);
|
||||||
|
int num2 = 0;
|
||||||
|
if(num == 0)
|
||||||
|
{
|
||||||
|
num = new Random().nextInt(-999, 1000);
|
||||||
|
}
|
||||||
|
if(num < input)
|
||||||
|
{
|
||||||
|
num2 = input-num;
|
||||||
|
}
|
||||||
|
else if (input < 0 && input < num) {
|
||||||
|
num2 = input - num;
|
||||||
|
}
|
||||||
|
else if (num > input) {
|
||||||
|
num2 = input - num;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
num +=1;
|
||||||
|
num2 -= 1;
|
||||||
|
}
|
||||||
|
if(num >= 1000 || num <= -1000 || num2 >= 1000 || num2 <= -1000)
|
||||||
|
return getComponents(input);
|
||||||
|
return new int[]{num, num2};
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,118 @@
|
|||||||
|
package com.kattis.ncpc25.log.rider;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.MissingFormatArgumentException;
|
||||||
|
|
||||||
|
public class C {
|
||||||
|
|
||||||
|
public static final int MINUTES_IN_A_DAY = 1_440;
|
||||||
|
|
||||||
|
public static void main(String[] args) throws Exception{
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
String start = in.readLine();
|
||||||
|
String end = in.readLine();
|
||||||
|
|
||||||
|
String out = countTime(start, end);
|
||||||
|
System.out.println(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String countTime(String start, String end)
|
||||||
|
{
|
||||||
|
if(start.equalsIgnoreCase(end))
|
||||||
|
{
|
||||||
|
return "7 days";
|
||||||
|
}
|
||||||
|
|
||||||
|
int startTime = formatedTimeToMin(start);
|
||||||
|
int endTime = formatedTimeToMin(end);
|
||||||
|
|
||||||
|
if(endTime < startTime)
|
||||||
|
{
|
||||||
|
endTime += MINUTES_IN_A_DAY*7;
|
||||||
|
}
|
||||||
|
|
||||||
|
int totalTime = endTime-startTime;
|
||||||
|
|
||||||
|
int days = totalTime / MINUTES_IN_A_DAY;
|
||||||
|
int hours = (totalTime - (days * MINUTES_IN_A_DAY)) / 60;
|
||||||
|
int minutes = (totalTime - (days * MINUTES_IN_A_DAY) - (hours * 60));
|
||||||
|
|
||||||
|
int components = 0;
|
||||||
|
if(days > 0)
|
||||||
|
{
|
||||||
|
components += 1;
|
||||||
|
}
|
||||||
|
if(hours > 0)
|
||||||
|
{
|
||||||
|
components += 1;
|
||||||
|
}
|
||||||
|
if(minutes > 0)
|
||||||
|
{
|
||||||
|
components += 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder out = new StringBuilder();
|
||||||
|
if(days > 0)
|
||||||
|
{
|
||||||
|
out.append(days).append(" day").append((days == 1?"":"s"));
|
||||||
|
}
|
||||||
|
if(hours > 0)
|
||||||
|
{
|
||||||
|
if(!out.isEmpty())
|
||||||
|
{
|
||||||
|
if(components == 2)
|
||||||
|
{
|
||||||
|
out.append(" and ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.append(hours).append(" hour").append((hours == 1?"":"s"));
|
||||||
|
}
|
||||||
|
if(minutes > 0)
|
||||||
|
{
|
||||||
|
if(!out.isEmpty())
|
||||||
|
{
|
||||||
|
if(components == 2)
|
||||||
|
{
|
||||||
|
out.append(" and ");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
out.append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
out.append(minutes).append(" minute").append((minutes == 1?"":"s"));
|
||||||
|
}
|
||||||
|
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int formatedTimeToMin(String formated)
|
||||||
|
{
|
||||||
|
String day, time;
|
||||||
|
day = formated.split(" ")[0];
|
||||||
|
time = formated.split(" ")[1];
|
||||||
|
int min = 0;
|
||||||
|
|
||||||
|
min += switch (day) {
|
||||||
|
case "Mon" -> MINUTES_IN_A_DAY;
|
||||||
|
case "Tue" -> MINUTES_IN_A_DAY*2;
|
||||||
|
case "Wed" -> MINUTES_IN_A_DAY*3;
|
||||||
|
case "Thu" -> MINUTES_IN_A_DAY*4;
|
||||||
|
case "Fri" -> MINUTES_IN_A_DAY*5;
|
||||||
|
case "Sat" -> MINUTES_IN_A_DAY*6;
|
||||||
|
case "Sun" -> MINUTES_IN_A_DAY*7;
|
||||||
|
default -> 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
String hour = time.split(":")[0];
|
||||||
|
String minute = time.split(":")[1];
|
||||||
|
|
||||||
|
min += Integer.parseInt(minute);
|
||||||
|
min += Integer.parseInt(hour)*60;
|
||||||
|
|
||||||
|
return min;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,61 @@
|
|||||||
|
package com.kattis.ncpc25.log.rider;
|
||||||
|
|
||||||
|
import java.awt.*;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
public class D {
|
||||||
|
public static void main(String[] args) throws Exception {
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
int count = Integer.parseInt(in.readLine());
|
||||||
|
Point[] points = new Point[count];
|
||||||
|
for(int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
String line = in.readLine();
|
||||||
|
int n1 = Integer.parseInt(line.split(" ")[0]);
|
||||||
|
int n2 = Integer.parseInt(line.split(" ")[1]);
|
||||||
|
points[i] = new Point(n1, n2);
|
||||||
|
}
|
||||||
|
|
||||||
|
double length = getTotalLength(points);
|
||||||
|
System.out.println(length);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getTotalLength(Point[] points)
|
||||||
|
{
|
||||||
|
points = sort(points);
|
||||||
|
double out = 0;
|
||||||
|
Point pLast = null;
|
||||||
|
for(Point p : points)
|
||||||
|
{
|
||||||
|
if(pLast == null)
|
||||||
|
{
|
||||||
|
pLast = p;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
out += pLast.distance(p);
|
||||||
|
}
|
||||||
|
return out;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Point[] sort(Point[] in)
|
||||||
|
{
|
||||||
|
ArrayList<Point> out = new ArrayList<>();
|
||||||
|
ArrayList<Point> left = new ArrayList<>(Arrays.stream(in).toList());
|
||||||
|
Point p1, p2, p3;
|
||||||
|
if(!left.isEmpty()) p1 = left.removeFirst();
|
||||||
|
if(!left.isEmpty()) p2 = left.removeFirst();
|
||||||
|
if(!left.isEmpty()) p3 = left.removeFirst();
|
||||||
|
|
||||||
|
//if(p3 == null)
|
||||||
|
//{
|
||||||
|
// out.put
|
||||||
|
//}
|
||||||
|
|
||||||
|
//if(p1.distance(p3))
|
||||||
|
|
||||||
|
return out.toArray(new Point[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,18 @@
|
|||||||
|
package com.kattis.ncpc25.log.rider;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
|
||||||
|
public class G {
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
int n,m,k;
|
||||||
|
String line = in.readLine();
|
||||||
|
n = Integer.parseInt(line.split(" ")[0]);
|
||||||
|
m = Integer.parseInt(line.split(" ")[1]);
|
||||||
|
k = Integer.parseInt(line.split(" ")[2]);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,67 @@
|
|||||||
|
package com.kattis.ncpc25.log.rider;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
import java.util.concurrent.atomic.AtomicLong;
|
||||||
|
|
||||||
|
public class J {
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
String line = in.readLine();
|
||||||
|
long N = Long.parseLong(line.split(" ")[0]);
|
||||||
|
long E = Long.parseLong(line.split(" ")[1]);
|
||||||
|
String out = jump(N, E);
|
||||||
|
System.out.println(out);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String jump(long N, long E)
|
||||||
|
{
|
||||||
|
ArrayList<Integer> levels = new ArrayList<>();
|
||||||
|
int count = 0;
|
||||||
|
int diff = 0;
|
||||||
|
long time = 0;
|
||||||
|
boolean inf = false;
|
||||||
|
boolean first = true;
|
||||||
|
do
|
||||||
|
{
|
||||||
|
time += E;
|
||||||
|
if(time % N == 0 && !first)
|
||||||
|
{
|
||||||
|
E++;
|
||||||
|
if(count < 11){
|
||||||
|
diff++;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
E--;
|
||||||
|
if(count < 11){
|
||||||
|
diff--;
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(count >= 10)
|
||||||
|
{
|
||||||
|
if(diff == 0)
|
||||||
|
{
|
||||||
|
inf = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(first) first = false;
|
||||||
|
}
|
||||||
|
while (E > 0);
|
||||||
|
if(inf)
|
||||||
|
{
|
||||||
|
return "infinity";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return time+"";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
package com.kattis.ncpc25.log.rider;
|
||||||
|
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
|
||||||
|
public class K {
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
|
||||||
|
int num = Integer.parseInt(in.readLine());
|
||||||
|
String[] signs = new String[num];
|
||||||
|
for(int i = 0; i < num; i++)
|
||||||
|
{
|
||||||
|
signs[i] = in.readLine();
|
||||||
|
}
|
||||||
|
int lastTop = 0;
|
||||||
|
int lastTopRound = 0;
|
||||||
|
for(String l : signs)
|
||||||
|
{
|
||||||
|
if(l.equalsIgnoreCase("/"))
|
||||||
|
{
|
||||||
|
System.out.println(lastTopRound);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
int limit = Integer.parseInt(l);
|
||||||
|
if(limit > lastTopRound)
|
||||||
|
{
|
||||||
|
int tmp = (int)Math.ceil(limit/10.0)*10;
|
||||||
|
if(tmp == 90)
|
||||||
|
{
|
||||||
|
lastTopRound = 100;
|
||||||
|
}
|
||||||
|
else if(tmp <= 160)
|
||||||
|
{
|
||||||
|
lastTopRound = tmp;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
System.out.println(limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,68 +0,0 @@
|
|||||||
package com.kattis.ncpc26.p2.pending;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
|
|
||||||
public class D {
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
|
||||||
|
|
||||||
char[][] board = new char[8][8];
|
|
||||||
|
|
||||||
for(int i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
board[i] = br.readLine().toCharArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
int[][] dig = {
|
|
||||||
{1,1}, {-1,1}, {-1,1}, {-1,-1}
|
|
||||||
};
|
|
||||||
|
|
||||||
for(int bx = 0; bx < 8; bx++)
|
|
||||||
{
|
|
||||||
for(int by = 0; by < 8; by++)
|
|
||||||
{
|
|
||||||
if(board[bx][by] == '*')
|
|
||||||
{
|
|
||||||
for(int i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
if(i == bx) continue;
|
|
||||||
if(board[i][by] == '*')
|
|
||||||
{
|
|
||||||
System.out.println("invalid");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(int i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
if(i == by) continue;
|
|
||||||
if(board[bx][i] == '*')
|
|
||||||
{
|
|
||||||
System.out.println("invalid");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for(int i = 0; i < 2; i++)
|
|
||||||
{
|
|
||||||
int[] mod = dig[i];
|
|
||||||
int x = mod[0];
|
|
||||||
int y = mod[1];
|
|
||||||
int base = (i==0?0:7);
|
|
||||||
for(int j = 0; j < 8; j++)
|
|
||||||
{
|
|
||||||
if(base+x*j == bx && y*j == by) continue;
|
|
||||||
if(board[base+x*j][y*j] == '*')
|
|
||||||
{
|
|
||||||
System.out.println("invalid");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println("valid");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,44 +0,0 @@
|
|||||||
package com.kattis.ncpc26.p2.pending;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.Scanner;
|
|
||||||
|
|
||||||
public class E {
|
|
||||||
public static void main(String[] args) throws IOException {
|
|
||||||
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
|
|
||||||
|
|
||||||
int n = Integer.parseInt(br.readLine());
|
|
||||||
|
|
||||||
int[] maxNumber = new int[n];
|
|
||||||
int[] minNumber = new int[n];
|
|
||||||
|
|
||||||
for(int i = 0; i < n; i++)
|
|
||||||
{
|
|
||||||
String hexNum = br.readLine().toUpperCase(Locale.ROOT);
|
|
||||||
|
|
||||||
if(hexNum.length() > 1 && (hexNum.startsWith("0") || hexNum.startsWith("D")))
|
|
||||||
{
|
|
||||||
hexNum = "d" + hexNum.substring(1);
|
|
||||||
}
|
|
||||||
{
|
|
||||||
minNumber[i] = Integer.parseInt(hexNum.replaceAll("B", "8").replaceAll("D", "0"), 16);
|
|
||||||
maxNumber[i] = Integer.parseInt(hexNum.replaceAll("8", "B").replaceAll("0", "D"), 16);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
int maxOut = 0;
|
|
||||||
int minOut = 0;
|
|
||||||
|
|
||||||
for(int i = 0; i < n; i++) {
|
|
||||||
minOut += minNumber[i];
|
|
||||||
maxOut += maxNumber[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
System.out.println(Integer.toHexString(maxOut).toUpperCase(Locale.ROOT));
|
|
||||||
System.out.println(Integer.toHexString(minOut).toUpperCase(Locale.ROOT));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user