From dafcadfd71644e08b06745891ba7a819a3dc52b2 Mon Sep 17 00:00:00 2001 From: KeshavAnandCode Date: Thu, 16 Apr 2026 20:16:51 -0500 Subject: [PATCH] failed skewer scurvy solution but the idea is there --- solutions/practice/SkewerScurvyEasy.java | 143 +++++++++++++++++++++++ 1 file changed, 143 insertions(+) create mode 100644 solutions/practice/SkewerScurvyEasy.java diff --git a/solutions/practice/SkewerScurvyEasy.java b/solutions/practice/SkewerScurvyEasy.java new file mode 100644 index 0000000..bd17a23 --- /dev/null +++ b/solutions/practice/SkewerScurvyEasy.java @@ -0,0 +1,143 @@ +// General imports + +import java.util.*; +import java.io.*; +import java.math.*; + +public class SkewerScurvyEasy { + static char[][] input; + static int[][] ids; + + public static void main(String[] args) { + + Scanner sc = new Scanner(System.in); + + int a = sc.nextInt(); + + for (int i = 0; i < a; i++) { + int count = 1; + int h = sc.nextInt(); + int w = sc.nextInt(); + input = new char[h][w]; + ids = new int[h][w]; + for (int k = 0; k < input.length; k++) { + String s = sc.next(); + for (int j = 0; j < input[0].length; j++) { + input[k][j] = s.charAt(j); + ids[k][j] = count; + count++; + } + } + boolean hitPillar = false; + + ArrayList safeNorth = new ArrayList<>(); + + for (int j = 0; j < w; j++) { + hitPillar = false; + for (int k = 0; k < h; k++) { + if (hitPillar && input[k][j] != '#') { + safeNorth.add(ids[k][j]); + } + + if (input[k][j] == '#') { + hitPillar = true; + } + } + + } + + String out = "Testcase " + i + " NORTH:"; + Collections.sort(safeNorth); + for (int n = 0; n < safeNorth.size(); n++) { + out = out + " " + safeNorth.get(n); + } + + System.out.println(out); + + hitPillar = false; + + ArrayList safeEast = new ArrayList<>(); + + for (int k = 0; k < h; k++) { + hitPillar = false; + + for (int j = w - 1; j >= 0; j--) { + if (hitPillar && input[k][j] != '#') { + safeEast.add(ids[k][j]); + } + + if (input[k][j] == '#') { + hitPillar = true; + } + } + + } + + out = "Testcase " + i + " EAST :"; + Collections.sort(safeEast); + for (int n = 0; n < safeEast.size(); n++) { + out = out + " " + safeEast.get(n); + } + + System.out.println(out); + + hitPillar = false; + + ArrayList safeSouth = new ArrayList<>(); + + for (int j = 0; j < w; j++) { + hitPillar = false; + + for (int k = h - 1; k >= 0; k--) { + if (hitPillar && input[k][j] != '#') { + safeSouth.add(ids[k][j]); + } + + if (input[k][j] == '#') { + hitPillar = true; + } + } + + } + + out = "Testcase " + i + " SOUTH:"; + Collections.sort(safeSouth); + for (int n = 0; n < safeSouth.size(); n++) { + out = out + " " + safeSouth.get(n); + } + + System.out.println(out); + + hitPillar = false; + + ArrayList safeWest = new ArrayList<>(); + + for (int k = 0; k < h; k++) { + hitPillar = false; + + for (int j = 0; j < w; j++) { + if (hitPillar && input[k][j] != '#') { + safeWest.add(ids[k][j]); + } + + if (input[k][j] == '#') { + hitPillar = true; + } + } + + } + + out = "Testcase " + i + " WEST :"; + Collections.sort(safeWest); + for (int n = 0; n < safeWest.size(); n++) { + out = out + " " + safeWest.get(n); + } + + System.out.println(out); + + } + + sc.close(); + + } +}