diff --git a/c/.idea/C.c b/c/.idea/C.c new file mode 100644 index 0000000..01639f2 --- /dev/null +++ b/c/.idea/C.c @@ -0,0 +1,77 @@ +#include +#include + +int main() +{ + int ship_x, ship_y; + int treasure_x, treasure_y; + int direction_x, direction_y; + int movement_help; + + scanf("%d %d", &ship_x, &ship_y); + scanf("%d %d", &treasure_x, &treasure_y); + + + + while (((ship_x == treasure_x) && (ship_y == treasure_y))==0){ + direction_x = ship_x - treasure_x; + direction_y = ship_y - treasure_y; + + //diagonal movement + if (abs(direction_x) == abs(direction_y)){ + //NortEeast movment + if((direction_x < 0) && (direction_y < 0)){ + printf("NE\n"); + ship_x -= direction_x; + ship_y -= direction_y; + } + //NortWest movement + else if((direction_x > 0) && (direction_y < 0)){ + printf("NW\n"); + ship_x -= direction_x; + ship_y -= direction_y; + } + //SouthWest movement + else if((direction_x > 0) && (direction_y > 0)){ + printf("SW\n"); + ship_x -= direction_x; + ship_y -= direction_y; + } + //SouthEast movement + else if((direction_x < 0) && (direction_y > 0)){ + printf("SE\n"); + ship_x -= direction_x; + ship_y -= direction_y; + } + } + else if((abs(direction_x) != abs(direction_y))){ + //horisontal / vertical movement + if(abs(direction_x) > abs(direction_y)){ + movement_help = abs(abs(direction_x) - abs(direction_y)); + //East movement + if(direction_x < 0){ + printf("E\n"); + ship_x += movement_help; + } + //West movement + if(direction_x > 0){ + printf("W\n"); + ship_x -= movement_help; + } + } + if(abs(direction_x) < abs(direction_y)){ + movement_help = abs( abs(direction_y) - abs(direction_x)); + //North Movement + if(direction_y < 0){ + printf("N\n"); + ship_y += movement_help; + } + //South Movement + if(direction_y > 0){ + printf("S\n"); + ship_y -= movement_help; + } + } + } + } +} \ No newline at end of file diff --git a/c/.idea/c.exe b/c/.idea/c.exe new file mode 100644 index 0000000..4f4ea75 Binary files /dev/null and b/c/.idea/c.exe differ diff --git a/c/.idea/realC.c b/c/.idea/realC.c new file mode 100644 index 0000000..e69de29 diff --git a/c/A.c b/c/A.c deleted file mode 100644 index 30815f4..0000000 --- a/c/A.c +++ /dev/null @@ -1,152 +0,0 @@ -#include -#include - -int main() -{ - int array[26]; - int time = 0; - char problem; - char RightOrWrong[10]; - int sum = 0; - int solved = 0; - int is_solved[26]; - - for (int i = 0 ; i < 26; i++){ - is_solved[i] = 0; - } - - for(int i = 0; i < 26; i++) - { - array[i] = 0; - } - - while(scanf("%d %c %s", &time, &problem, &RightOrWrong) == 3 && time != -1){ - - - switch (problem){ - case 'A': - if (strcmp(RightOrWrong, "wrong")==0){ - array[0] += 20; - }else{ - array[0] += time; - solved += 1; - is_solved[0] = 1; - } - break; - case 'B': - if (strcmp(RightOrWrong, "wrong")==0){ - array[1] += 20; - }else{ - array[1] += time; - solved += 1; - is_solved[1] = 1; - - } - break; - case 'C': - if (strcmp(RightOrWrong, "wrong")==0){ - array[2] += 20; - }else{ - array[2] += time; - solved += 1; - is_solved[2] = 1; - - } - break; - case 'D': - if (strcmp(RightOrWrong, "wrong")==0){ - array[3] += 20; - }else{ - array[3] += time; - solved += 1; - is_solved[3] = 1; - - } - break; - case 'E': - if (strcmp(RightOrWrong, "wrong")==0){ - array[4] += 20; - }else{ - array[4] += time; - solved += 1; - is_solved[4] = 1; - - } - break; - case 'F': - if (strcmp(RightOrWrong, "wrong")==0){ - array[5] += 20; - }else{ - array[5] += time; - solved += 1; - is_solved[5] = 1; - - } - break; - case 'G': - if (strcmp(RightOrWrong, "wrong")==0){ - array[6] += 20; - }else{ - array[6] += time; - solved += 1; - is_solved[6] = 1; - - } - break; - case 'H': - if (strcmp(RightOrWrong, "wrong")==0){ - array[7] += 20; - }else{ - array[7] += time; - solved += 1; - is_solved[7] = 1; - - } - break; - case 'I': - if (strcmp(RightOrWrong, "wrong")==0){ - array[8] += 20; - }else{ - array[8] += time; - solved += 1; - is_solved[8] = 1; - - } - break; - case 'J': - if (strcmp(RightOrWrong, "wrong")==0){ - array[9] += 20; - }else{ - array[9] += time; - solved += 1; - is_solved[9] = 1; - - } - break; - case 'K': - if (strcmp(RightOrWrong, "wrong")==0){ - array[10] += 20; - }else{ - array[10] += time; - solved += 1; - is_solved[10] = 1; - - } - break; - default: - return 0; - break; - - } - } - for(int i = 0; i <= 26; i++) - { - if(is_solved[i]==1){ - sum += array[i]; - } - } - - - printf("%d %d", solved, sum); -return 0; -} \ No newline at end of file diff --git a/java/NCPC26-practive-final/.gitignore b/java/.gitignore similarity index 100% rename from java/NCPC26-practive-final/.gitignore rename to java/.gitignore diff --git a/java/NCPC26-practive-final/.idea/.gitignore b/java/.idea/.gitignore similarity index 77% rename from java/NCPC26-practive-final/.idea/.gitignore rename to java/.idea/.gitignore index 30cf57e..13566b8 100644 --- a/java/NCPC26-practive-final/.idea/.gitignore +++ b/java/.idea/.gitignore @@ -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 diff --git a/java/.idea/gradle.xml b/java/.idea/gradle.xml new file mode 100644 index 0000000..14746e7 --- /dev/null +++ b/java/.idea/gradle.xml @@ -0,0 +1,16 @@ + + + + + + \ No newline at end of file diff --git a/java/.idea/misc.xml b/java/.idea/misc.xml new file mode 100644 index 0000000..f16dea7 --- /dev/null +++ b/java/.idea/misc.xml @@ -0,0 +1,10 @@ + + + + + + + + + + \ No newline at end of file diff --git a/java/.idea/vcs.xml b/java/.idea/vcs.xml new file mode 100644 index 0000000..6c0b863 --- /dev/null +++ b/java/.idea/vcs.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/java/NCPC26-practive-final/settings.gradle b/java/NCPC26-practive-final/settings.gradle deleted file mode 100644 index 004ff71..0000000 --- a/java/NCPC26-practive-final/settings.gradle +++ /dev/null @@ -1 +0,0 @@ -rootProject.name = 'NCPC26-practive-final' \ No newline at end of file diff --git a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/B.java b/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/B.java deleted file mode 100644 index 849bae5..0000000 --- a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/B.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.kattis.ncpc26.pf; - -public class B { -} diff --git a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/D.java b/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/D.java deleted file mode 100644 index 8f593a0..0000000 --- a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/D.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.kattis.ncpc26.pf; - -public class D { -} diff --git a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/E.java b/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/E.java deleted file mode 100644 index 6292102..0000000 --- a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/E.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.kattis.ncpc26.pf; - -public class E { -} diff --git a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/F.java b/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/F.java deleted file mode 100644 index 7e4f56f..0000000 --- a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/F.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.kattis.ncpc26.pf; - -public class F { -} diff --git a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/G.java b/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/G.java deleted file mode 100644 index a5da5d5..0000000 --- a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/G.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.kattis.ncpc26.pf; - -public class G { -} diff --git a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/I.java b/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/I.java deleted file mode 100644 index 8eff218..0000000 --- a/java/NCPC26-practive-final/src/main/java/com/kattis/ncpc26/pf/I.java +++ /dev/null @@ -1,4 +0,0 @@ -package com.kattis.ncpc26.pf; - -public class I { -} diff --git a/java/NCPC26-practive-final/build.gradle b/java/build.gradle similarity index 73% rename from java/NCPC26-practive-final/build.gradle rename to java/build.gradle index c1a2123..973cc48 100644 --- a/java/NCPC26-practive-final/build.gradle +++ b/java/build.gradle @@ -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' } diff --git a/java/NCPC26-practive-final/gradle/wrapper/gradle-wrapper.jar b/java/gradle/wrapper/gradle-wrapper.jar similarity index 100% rename from java/NCPC26-practive-final/gradle/wrapper/gradle-wrapper.jar rename to java/gradle/wrapper/gradle-wrapper.jar diff --git a/java/NCPC26-practive-final/gradle/wrapper/gradle-wrapper.properties b/java/gradle/wrapper/gradle-wrapper.properties similarity index 79% rename from java/NCPC26-practive-final/gradle/wrapper/gradle-wrapper.properties rename to java/gradle/wrapper/gradle-wrapper.properties index 6a8e5c4..9b6125c 100644 --- a/java/NCPC26-practive-final/gradle/wrapper/gradle-wrapper.properties +++ b/java/gradle/wrapper/gradle-wrapper.properties @@ -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 diff --git a/java/NCPC26-practive-final/gradlew b/java/gradlew old mode 100755 new mode 100644 similarity index 100% rename from java/NCPC26-practive-final/gradlew rename to java/gradlew diff --git a/java/NCPC26-practive-final/gradlew.bat b/java/gradlew.bat similarity index 96% rename from java/NCPC26-practive-final/gradlew.bat rename to java/gradlew.bat index ac1b06f..107acd3 100644 --- a/java/NCPC26-practive-final/gradlew.bat +++ b/java/gradlew.bat @@ -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 diff --git a/java/settings.gradle b/java/settings.gradle new file mode 100644 index 0000000..7ef4969 --- /dev/null +++ b/java/settings.gradle @@ -0,0 +1 @@ +rootProject.name = 'java' \ No newline at end of file diff --git a/java/src/main/java/B.java b/java/src/main/java/B.java new file mode 100644 index 0000000..bf14f80 --- /dev/null +++ b/java/src/main/java/B.java @@ -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 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 + 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); + } +} diff --git a/java/src/main/java/D.java b/java/src/main/java/D.java new file mode 100644 index 0000000..ba41b37 --- /dev/null +++ b/java/src/main/java/D.java @@ -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"); + } +} diff --git a/java/src/main/java/E.java b/java/src/main/java/E.java new file mode 100644 index 0000000..e9802eb --- /dev/null +++ b/java/src/main/java/E.java @@ -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 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; + } +} diff --git a/java/src/main/java/I.java b/java/src/main/java/I.java new file mode 100644 index 0000000..d2c16e8 --- /dev/null +++ b/java/src/main/java/I.java @@ -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 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); + } + } +} diff --git a/java/src/main/java/K.java b/java/src/main/java/K.java new file mode 100644 index 0000000..f288579 --- /dev/null +++ b/java/src/main/java/K.java @@ -0,0 +1,25 @@ +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.util.ArrayList; + +public class K { + + static record Pair(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> 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)); + } + + + } +} diff --git a/py/B.py b/py/B.py deleted file mode 100644 index 21807bc..0000000 --- a/py/B.py +++ /dev/null @@ -1,23 +0,0 @@ -import sys - -l = 0 -r = 1001 -m = 500 -temp = m - -for i in range(10): - print(m) - sys.stdout.flush() - - term = input() - - if term == "correct": - exit() - elif term == "lower": - temp = m - m = (l + m) // 2 - r = temp - else: - temp = m - m = (m + r) // 2 - l = temp diff --git a/py/C.py b/py/C.py deleted file mode 100644 index 40546f9..0000000 --- a/py/C.py +++ /dev/null @@ -1,12 +0,0 @@ -ball = 1 - -for i in range(5): - j = int(input()) - k = int(input()) - - if j == ball: - ball = k - elif k == ball: - ball = j - -print(ball) \ No newline at end of file diff --git a/py/J.py b/py/J.py deleted file mode 100644 index 1ce2976..0000000 --- a/py/J.py +++ /dev/null @@ -1,4 +0,0 @@ -w = int(input()) -l = int(input()) - -print(w*l) \ No newline at end of file diff --git a/py/L.py b/py/L.py new file mode 100644 index 0000000..7a4b578 --- /dev/null +++ b/py/L.py @@ -0,0 +1,38 @@ +import sys + +for line in sys.stdin: + pices = int(line) + + if (pices == 0): + print(0) + exit() + + arr = list() + arr = map(int, input().split()) + + ar = sorted(arr) + + half = ar[pices-1] / 2 + + i = 0 + index = 0 + closest = 1001 + + if (pices == 1): + print(ar[0]) + exit() + + while ar[i] <= half: + i += 1 + + if i > 0: + if (ar[i] - half) <= closest: + closest = (ar[i] - half) + index = i + if (half - ar[i-1]) <= closest: + closest = (ar[i-1] - half) + index = i-1 + else: + index = 0 + + print(max((ar[pices-1] - ar[index]), ar[index])) \ No newline at end of file diff --git a/py/good.txt b/py/good.txt new file mode 100644 index 0000000..6025383 --- /dev/null +++ b/py/good.txt @@ -0,0 +1,26 @@ +3 +400 199 201 +3 +400 202 199 +3 +400 201 198 +2 +500 100 +2 +101 99 +3 +100 100 100 +3 +100 200 300 +3 +1000 1 1 +3 +1000 500 100 +3 +100 101 99 +3 +100 150 50 +4 +200 400 200 100 +7 +100 100 900 500 500 1000 400 diff --git a/py/input.txt b/py/input.txt new file mode 100644 index 0000000..f9e50f2 --- /dev/null +++ b/py/input.txt @@ -0,0 +1,22 @@ +3 +401 600 1000 +3 +1 600 1000 +2 +1 2 +2 +1 1 +3 +1 1 2 +4 +1 2 1 1 +4 +1 2 2 1 +4 +1 2 2 2 +4 +400 1000 1000 1000 +5 +1000 1000 1000 998 22 +4 +300 500 150 100 \ No newline at end of file diff --git a/py/newL.py b/py/newL.py new file mode 100644 index 0000000..e69de29