Rezultati

Up. imeNalogaJezikRezultatČas oddaje
cimpricevi-angelcki-2019 Moderna umetnost C 100/100OK 09. maj '19 @ 18:30

Test Točke Porabljen spomin Porabljen čas Status
#1 [več] 20/20 1,461 MiB 0,000 s OK
#2 [več] 20/20 1,523 MiB 0,000 s OK
#3 [več] 20/20 1,496 MiB 0,000 s OK
#4 [več] 20/20 1,523 MiB 0,000 s OK
#5 [več] 20/20 1,523 MiB 0,005 s OK

Ocenjevani program (moderna.c):
#include <stdio.h>
#include <stdlib.h>

int tab[103][103];

#define min(a, b) (a < b ? a : b)
#define max(a, b) (a > b ? a : b)

int clamp(int low, int high, int val) 
{
    return min(high, max(low, val));
}

void swap(int* a, int* b)
{
    int tmp = *a;
    *a = *b;
    *b = tmp;
}


int main(){
    int w,h,n;
    scanf("%d%d%d",&w,&h,&n);

    int a,b,c,d;
    int o = 0;
    int st = 0;
    for(int i = 0; i < n; i++){
        scanf("%d %d %d %d",&a,&b,&c,&d);

        if ((a < 1 && c < 1) || (a > w && c > w) || (b < 1 && d < 1) || (b > h && d > h)) 
            continue;
        
        ++st;

        int x1 = clamp(1, w, a);
        int y1 = clamp(1, h, b);
        int x2 = clamp(1, w, c);
        int y2 = clamp(1, h, d);

        if (x2 < x1) {
            swap(&x1, &x2);
            swap(&y1, &y2);
        }

        int sirina = abs(x2 - x1) + 1;
        int visina = abs(y2 - y1) + 1;
        y1 = min(y1, y2);

        // printf("%d %d %d %d\n", x1, y1, sirina, visina);

        for (int row = 0; row < visina; ++row) {
            for (int col = 0; col < sirina; ++col) {
                tab[row + y1][col + x1] += 1;
            }
        }
    }
    printf("+");
    for(int i = 0; i < w; i++){
        printf("-");
    }
    printf("+\n");
    for(int j = 1; j < h+1; j++){
        printf("|");
                for(int k = 1; k < w+1;k++){
                    switch(tab[j][k]){
                        case 0:
                            printf(" ");
                            break;
                         case 1:
                            printf(".");
                            break;
                             case 2:
                            printf(":");
                            break;
                             case 3:
                            printf("-");
                            break;
                             case 4:
                            printf("=");
                            break;
                             case 5:
                            printf("+");
                            break;
                             case 6:
                            printf("*");
                            break;
                             case 7:
                            printf("$");
                            break;
                             case 8:
                            printf("#");
                            break;
                            case 9:
                            printf("%%");
                            break;
                            case 10:
                            printf("@");
                            break;
                        default:
                            printf("@");
                            break;

                    }
                }
        printf("|\n");
    }
    printf("+");
    for(int i = 0; i < w; i++){
        printf("-");
    }
    printf("+\n");

    printf("%d pravokotnikov na belem\n", st);

    return 0;
}