Go to diff to previous submission
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> short nlp[15000]; short neigh[11000][21000]; char visited[15000]; short queue[25000]; int qstart, qend; int points; void qreset() { qstart = 0; qend = 0; } int qpush(int n) { if (visited[n]) return 0; visited[n] = 1; //printf("push %d @ %d\n", n, qend); queue[qend++] = n; return 1; } int qpop() { if (qstart==qend) return -1; return queue[qstart++]; } int c() { int root, node, i, paws, ispaw, isbun=0; for (root=1; root<points+1; root++) { if (visited[root]) continue; //printf("root %d\n", root); qreset(); qpush(root); paws = 0; while (1) { node = qpop(); if (node < 0) break; ispaw = 0; for (i=0; i<nlp[node]; i++) { ispaw += qpush(neigh[node][i]); } if (!ispaw) paws++; } if (paws >= 4) isbun = 1; } return isbun; } int main(int argc, char **argv) { int rv, i, lines, p1, p2; while (1) { if (rv != 2) break; for (i=0; i<lines; i++) { neigh[p1][nlp[p1]++] = p2; neigh[p2][nlp[p2]++] = p1; } } return 0; }
--- c5.s980.cteam089.fn.c.0.fn.c +++ c5.s1010.cteam089.fn.c.0.fn.c @@ -4,8 +4,8 @@ #include <math.h> -int nlp[15000]; -int neigh[15000][25000]; -int visited[15000]; -int queue[25000]; +short nlp[15000]; +short neigh[11000][21000]; +char visited[15000]; +short queue[25000]; int qstart, qend; int points; @@ -33,4 +33,5 @@ for (root=1; root<points+1; root++) { if (visited[root]) continue; + //printf("root %d\n", root); qreset(); qpush(root);