summaryrefslogtreecommitdiffstats
path: root/šola/p1
diff options
context:
space:
mode:
authorAnton Luka Šijanec <anton@sijanec.eu>2023-11-29 18:07:34 +0100
committerAnton Luka Šijanec <anton@sijanec.eu>2023-11-29 18:07:34 +0100
commit67c73601247dc80a319f88dde243bce20bd11f92 (patch)
treec9b556f4d1407863d563dd46148c7f45178589ad /šola/p1
parentMerge branch 'master' of ssh://ni/var/lib/git/sijanec/r (diff)
downloadr-67c73601247dc80a319f88dde243bce20bd11f92.tar
r-67c73601247dc80a319f88dde243bce20bd11f92.tar.gz
r-67c73601247dc80a319f88dde243bce20bd11f92.tar.bz2
r-67c73601247dc80a319f88dde243bce20bd11f92.tar.lz
r-67c73601247dc80a319f88dde243bce20bd11f92.tar.xz
r-67c73601247dc80a319f88dde243bce20bd11f92.tar.zst
r-67c73601247dc80a319f88dde243bce20bd11f92.zip
Diffstat (limited to 'šola/p1')
-rw-r--r--šola/p1/dn/DN05_63230317.java60
-rw-r--r--šola/p1/dn/Plo.java19
2 files changed, 79 insertions, 0 deletions
diff --git a/šola/p1/dn/DN05_63230317.java b/šola/p1/dn/DN05_63230317.java
new file mode 100644
index 0000000..b46b5d1
--- /dev/null
+++ b/šola/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/šola/p1/dn/Plo.java b/šola/p1/dn/Plo.java
new file mode 100644
index 0000000..32a708f
--- /dev/null
+++ b/šola/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);
+ }
+}