From 67c73601247dc80a319f88dde243bce20bd11f92 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Luka=20=C5=A0ijanec?= Date: Wed, 29 Nov 2023 18:07:34 +0100 Subject: DN05 --- "\305\241ola/p1/dn/DN05_63230317.java" | 60 ++++++++++++++++++++++++++++++++++ "\305\241ola/p1/dn/Plo.java" | 19 +++++++++++ 2 files changed, 79 insertions(+) create mode 100644 "\305\241ola/p1/dn/DN05_63230317.java" create mode 100644 "\305\241ola/p1/dn/Plo.java" diff --git "a/\305\241ola/p1/dn/DN05_63230317.java" "b/\305\241ola/p1/dn/DN05_63230317.java" new file mode 100644 index 0000000..b46b5d1 --- /dev/null +++ "b/\305\241ola/p1/dn/DN05_63230317.java" @@ -0,0 +1,60 @@ +import java.util.*; +public class DN05_63230317 { + public static void main (String[] args) { + Scanner sc = new Scanner(System.in); + int[/* tetromino */][/* zgoraj=0 spodaj=1 */][/* stolpec */] tetro = { + {{0, 0, 0, 0}, {1, 1, 1, 1}} // 0 + ,{{0}, {4}} // 1 + ,{{0, 0}, {2, 2}} // 2 + ,{{1, 0, 1}, {2, 2, 2}} // 3 + ,{{1, 0}, {2, 3}} // 4 + ,{{0, 0, 0}, {1, 2, 1}} // 5 + ,{{0, 1}, {3, 2}} // 6 + ,{{0, 2}, {3, 3}} // 7 + ,{{1, 1, 0}, {2, 2, 2}} // 8 + ,{{0, 0}, {1, 3}} // 9 + ,{{0, 0, 0}, {2, 1, 1}} // 10 + ,{{2, 0}, {3, 3}} // 11 + ,{{0, 0, 0}, {1, 1, 2}} // 12 + ,{{0, 0}, {3, 1}} // 13 + ,{{0, 1, 1}, {2, 2, 2}} // 14 + ,{{0, 0, 1}, {1, 2, 2}} // 15 + ,{{1, 0}, {3, 2}} // 16 + ,{{1, 0, 0}, {2, 2, 1}} // 17 + ,{{0, 1}, {2, 3}} // 18 + }; + int višine[] = new int[2005]; + int n = sc.nextInt(); + for (int unused = 0; unused < n; unused++) { + int l = sc.nextInt(); + int x = sc.nextInt()+1000; + int najbližji = 69; + for (int i = 0; i < tetro[l][0].length; i++) { + if (najbližji == 69 || višine[x+i]+tetro[l][1][i] > višine[x+najbližji]+tetro[l][1][najbližji]) + najbližji = i; + } + if (System.getenv("DN05_DEBUG") != null) { + System.err.println("pade tetromino broj " + l + " na " + (x-1000) + " in stanje je"); + System.err.println("najbližji je " + najbližji); + } + višine[x+najbližji] += tetro[l][1][najbližji] - tetro[l][0][najbližji]; + for (int i = 0; i < tetro[l][0].length; i++) { + if (i == najbližji) + continue; + višine[x+i] = višine[x+najbližji]+tetro[l][0][najbližji]-tetro[l][0][i]; + } + if (System.getenv("DN05_DEBUG") != null) { + for (int i = 0; i < višine.length; i++) { + if (višine[i] == 0) + continue; + System.err.println((i-1000) + ": " + višine[i]); + } + } + } + for (int i = 0; i < višine.length; i++) { + if (višine[i] == 0) + continue; + System.out.println((i-1000) + ": " + višine[i]); + } + } +} diff --git "a/\305\241ola/p1/dn/Plo.java" "b/\305\241ola/p1/dn/Plo.java" new file mode 100644 index 0000000..32a708f --- /dev/null +++ "b/\305\241ola/p1/dn/Plo.java" @@ -0,0 +1,19 @@ +import java.util.*; +public class Plo{ + public static void main(String[] args) { + Scanner sc = new Scanner(System.in); + long visina = sc.nextInt(); + long sirina = sc.nextInt(); + long k = sc.nextInt(); + long stPloscic = (visina/(1 << k))*(sirina/(1 << k)); + for (long i = k - 1; i >= 0; i--) { + if ((sirina & (1 << i)) > 0) + stPloscic += (visina / (1 << i)); + if ((visina & (1 << i)) > 0) + stPloscic += (sirina / (1 << i)); + if ((sirina & (1 << i)) > 0 && (visina & (1 << i)) > 0) + stPloscic--; + } + System.out.println(stPloscic); + } +} -- cgit v1.2.3