NCPC26 ending

This commit is contained in:
Joel committed 2026-10-03 16:16:18 +02:00
1 parent fbd41d8ac7
commit 2820c84507
34 files changed
+612 -311

No files matched your search

File renamed without changes.
@@ -3,8 +3,6 @@
/workspace.xml
# Editor-based HTTP Client requests
/httpRequests/
# Ignored default folder with query files
/queries/
# Datasource local storage ignored files
/dataSources/
/dataSources.local.xml
+16
View File
@@ -0,0 +1,16 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="GradleSettings">
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</GradleProjectSettings>
</option>
</component>
</project>
+10
View File
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="FrameworkDetectionExcludesConfiguration">
<file type="web" url="file://$PROJECT_DIR$" />
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_21" default="true" project-jdk-name="21" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>
+6
View File
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
</component>
</project>
@@ -1 +0,0 @@
rootProject.name = 'NCPC26-practive-final'
@@ -1,4 +0,0 @@
package com.kattis.ncpc26.pf;
public class B {
}
@@ -1,4 +0,0 @@
package com.kattis.ncpc26.pf;
public class D {
}
@@ -1,4 +0,0 @@
package com.kattis.ncpc26.pf;
public class E {
}
@@ -1,4 +0,0 @@
package com.kattis.ncpc26.pf;
public class F {
}
@@ -1,4 +0,0 @@
package com.kattis.ncpc26.pf;
public class G {
}
@@ -1,4 +0,0 @@
package com.kattis.ncpc26.pf;
public class I {
}
@@ -2,7 +2,7 @@ plugins {
id 'java'
}
group = 'com.kattis.ncpc26.pf'
group = 'org.example'
version = '1.0-SNAPSHOT'
repositories {
@@ -10,7 +10,7 @@ repositories {
}
dependencies {
testImplementation platform('org.junit:junit-bom:6.0.0')
testImplementation platform('org.junit:junit-bom:5.10.0')
testImplementation 'org.junit.jupiter:junit-jupiter'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'
}
@@ -1,6 +1,6 @@
#Fri Sep 18 10:45:37 CEST 2026
#Sat Oct 03 11:00:43 CEST 2026
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-9.6.0-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-9.1.0-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
View File
File renamed without changes.
+89 -89
View File
@@ -1,89 +1,89 @@
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
@rem
@rem Copyright 2015 the original author or authors.
@rem
@rem Licensed under the Apache License, Version 2.0 (the "License");
@rem you may not use this file except in compliance with the License.
@rem You may obtain a copy of the License at
@rem
@rem https://www.apache.org/licenses/LICENSE-2.0
@rem
@rem Unless required by applicable law or agreed to in writing, software
@rem distributed under the License is distributed on an "AS IS" BASIS,
@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################
@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal
set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%
@rem Resolve any "." and ".." in APP_HOME to make it shorter.
for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome
set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto execute
echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe
if exist "%JAVA_EXE%" goto execute
echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
goto fail
:execute
@rem Setup the command line
set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd
:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1
:mainEnd
if "%OS%"=="Windows_NT" endlocal
:omega
+1
View File
@@ -0,0 +1 @@
rootProject.name = 'java'
+31
View File
@@ -0,0 +1,31 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
public class B {
record Pair<K, V>(K key, V value)
{}
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String input = br.readLine();
int n = Integer.parseInt(input.split(" ")[0]);
int k = Integer.parseInt(input.split(" ")[1]);
int[] slots = new int[k];
HashMap<String>
for(int i = 0; i < n; i++)
{
input = br.readLine();
int org = Integer.parseInt(input.split(" ")[0])-1;
int dest = Integer.parseInt(input.split(" ")[1])-1;
slots[org]--;
slots[dest]++;
}
long redudent = Arrays.stream(slots).filter((i) -> i == 0).count();
System.out.println(redudent);
}
}
+52
View File
@@ -0,0 +1,52 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class D {
public static void main(String[] args) throws Exception {
String spondee = "--";
String trocha = "-u";
String dactyl = "-uu";
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String in = br.readLine();
int spondees = 0;
int dactyls = 0;
for(int i = 0; i < 5; i++)
{
if(in.startsWith(spondee))
{
spondees++;
in = in.substring(spondee.length());
}
else if(in.startsWith(dactyl))
{
dactyls++;
in = in.substring(dactyl.length());
}
else
{
System.out.println("no");
return;
}
}
if(!(spondees + dactyls == 5))
{
System.out.println("no");
return;
}
if(in.length() > 2)
{
System.out.println("no");
return;
}
if(!(in.endsWith(spondee) || in.endsWith(trocha)))
{
System.out.println("no");
return;
}
System.out.println("yes");
}
}
+181
View File
@@ -0,0 +1,181 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
public class E {
public static void main(String[] args) throws Exception {
char[][] nums = {
// 0
{
'.', '#', '#', '.',
'#', '.', '.', '#',
'#', '.', '.', '#',
'.', '.', '.', '.',
'#', '.', '.', '#',
'#', '.', '.', '#',
'.', '#', '#', '.'
},
// 1
{
'.', '.', '.', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '.', '.', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '.', '.', '.'
},
// 2
{
'.', '#', '#', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '#', '#', '.',
'#', '.', '.', '.',
'#', '.', '.', '.',
'.', '#', '#', '.'
},
// 3
{
'.', '#', '#', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '#', '#', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '#', '#', '.'
},
// 4
{
'.', '.', '.', '.',
'#', '.', '.', '#',
'#', '.', '.', '#',
'.', '#', '#', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '.', '.', '.'
},
// 5
{
'.', '#', '#', '.',
'#', '.', '.', '.',
'#', '.', '.', '.',
'.', '#', '#', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '#', '#', '.'
},
// 6
{
'.', '#', '#', '.',
'#', '.', '.', '.',
'#', '.', '.', '.',
'.', '#', '#', '.',
'#', '.', '.', '#',
'#', '.', '.', '#',
'.', '#', '#', '.'
},
// 7
{
'.', '#', '#', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '.', '.', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '.', '.', '.'
},
// 8
{
'.', '#', '#', '.',
'#', '.', '.', '#',
'#', '.', '.', '#',
'.', '#', '#', '.',
'#', '.', '.', '#',
'#', '.', '.', '#',
'.', '#', '#', '.'
},
// 9
{
'.', '#', '#', '.',
'#', '.', '.', '#',
'#', '.', '.', '#',
'.', '#', '#', '.',
'.', '.', '.', '#',
'.', '.', '.', '#',
'.', '#', '#', '.'
}
};
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringBuilder sb = new StringBuilder();
for(int i = 0; i < 7; i++)
{
sb.append(br.readLine());
}
char[] input = sb.toString().toCharArray();
ArrayList<Integer> posibleNums = new ArrayList<>();
for(int i = 0; i < 10; i++)
{
if(Arrays.equals(nums[i], input))
{
posibleNums.add(i);
}
}
if(!posibleNums.isEmpty())
{
System.out.println(posibleNums.get(0));
return;
}
for(int i = 10; i < 100; i++)
{
char[] compiledNum = compileNum(nums, i);
if(Arrays.equals(compiledNum, input))
{
posibleNums.add(i);
}
}
if(posibleNums.isEmpty())
{
System.out.println("impossible");
return;
}
posibleNums.sort(Integer::compareTo);
sb = new StringBuilder();
StringBuilder finalSb = sb;
posibleNums.forEach((i) -> {
finalSb.append(i).append(" ");
});
String output = sb.toString().trim();
System.out.println(output);
}
private static char[] compileNum(char[][] nums, int i)
{
int tio = i / 10;
int ett = i % 10;
char[] out = new char[28];
for(int j = 0; j < 28; j++)
{
out[j] = nums[tio][j] == nums[ett][j] ? '.' : '#';
}
return out;
}
}
+34
View File
@@ -0,0 +1,34 @@
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class I {
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String crewStr = br.readLine();
String hermit1Str = br.readLine();
String hermit2Str = br.readLine();
String hermit3Str = br.readLine();
int crew = Integer.parseInt(crewStr);
int hermit1 = Integer.parseInt(hermit1Str);
int hermit2 = Integer.parseInt(hermit2Str);
int hermit3 = Integer.parseInt(hermit3Str);
ArrayList<Integer> hermits = new ArrayList<>();
hermits.add(hermit1);
hermits.add(hermit2);
hermits.add(hermit3);
hermits.sort(Integer::compareTo);
if(hermits.get(0) + crew >= hermits.get(1))
{
System.out.println("impossible");
}
else
{
System.out.println(hermits.get(0) + crew);
}
}
}
+25
View File
@@ -0,0 +1,25 @@
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
public class K {
static record Pair<K, V>(K key, V value)
{}
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int numTrees = Integer.parseInt(br.readLine());
ArrayList<Pair<Integer, Integer>> trees = new ArrayList<>();
for(int i = 0; i < numTrees; i++)
{
String str = br.readLine();
int i1 = Integer.parseInt(str.split(" ")[0]);
int i2 = Integer.parseInt(str.split(" ")[1]);
trees.add(new Pair<>(i1, i2));
}
}
}