Rezultati

Up. imeNalogaJezikRezultatČas oddaje
jam-2017 Prijateljske besede C 100/100OK 20. apr '17 @ 17:35

Test Točke Porabljen spomin Porabljen čas Status
#1 12/12 1,531 MiB 0,005 s OK
#2 12/12 1,746 MiB 0,005 s OK
#3 12/12 10,191 MiB 0,242 s OK
#4 12/12 10,051 MiB 0,303 s OK
#5 13/13 9,891 MiB 0,224 s OK
#6 13/13 10,008 MiB 0,261 s OK
#7 13/13 8,418 MiB 0,151 s OK
#8 13/13 9,984 MiB 0,279 s OK

Ocenjevani program (2.c):
#include <stdio.h>
#include <string.h>

char tab[3000][3000];
char bes[3000][11];
int n;
char not[3000];

int primerjaj(char* bes1, char* bes2) {
    for (int i = 0; i < 3; i++)
        if (bes1[i] != bes2[i])
            return 0;
    return 1;
}

int podobna(char* bes1, char* bes2) {
    if (primerjaj(bes1, bes2))
        return 1;
    if (primerjaj(&bes1[strlen(bes1) - 3], &bes2[strlen(bes2) - 3]))
        return 1;
    return 0;
}

void rek(int y) {
    if (not[y])
        return;
    not[y] = 1;
    
    for (int x = 0; x < n; x++) {
        if (tab[x][y])
            rek(x);
    }
}

int main() {
    scanf("%d", &n);
    
    for (int i = 0; i < n; i++)
        scanf("%s", &bes[i][0]);
    
    for (int y = 0; y < n; y++)
        for (int x = y + 1; x < n; x++)
            if (podobna(bes[x], bes[y])) {
                tab[x][y] = 1;
                tab[y][x] = 1;
            }
    
    rek(0);
    
    
    
    int ret = 0;
    for (int i = 0; i < n; i++)
        if (not[i])
            ret++;
    
    printf("%d\n", ret);
}