// gcc -O3 -o sync sync.c #include #include #include #include #include #include #include int w[9000000], a, l, i, j, k, t, mor[10][1000000]; char ch[1000000]; int eq(int *g, int *d, int l){ for(; l--; ) if(g[l] != d[l]) return 0; return 1; }//*/ void out(char* ch){ printf("%s\n", ch); exit(0); } void main(int ac, char **av){ FILE *in = fopen(av[1], "r"); if(ac < 2) out("Usage: ./sync morphism_file"); for(fgets(ch, 200000, in), a = 0; strcmp(ch, "\n"); fgets(ch, 200000, in), a++){ if(!a) l = strlen(ch)-1; else if(l != strlen(ch)-1) out("the morphism is not uniform"); for(j = l; j--; ) mor[a][j] = ch[j]-'0'; } printf("%d-uniform %d-ary morphism\n", l, a); for(i = 0; i < a; i++){ for(t = 0; t < l; t++) w[t] = mor[i][t]; for(j = 0; j < a; j++){ for(t = 0; t < l; t++) w[l+t] = mor[j][t]; for(k = 0; k < a; k++) for(t = 1; t < l; t++) if(eq(w+t, mor[k], l)) out("the morphism is not synchronizing"); } } out("the morphism is synchronizing"); }