Submission #1047259

#TimeUsernameProblemLanguageResultExecution timeMemory
1047259sleepntsheepNewspapers (CEOI21_newspapers)C11
4 / 100
1 ms348 KiB
#include <stdio.h> #include <stdlib.h> #define N 1005 int eo[N], *eh[N]; void pus(int i, int j) { int o = eo[i]++; if (!o) eh[i] = (int*)malloc(2 * sizeof **eh); else if (0 == (o & o - 1)) eh[i] = (int*)realloc(eh[i], 2 * o * sizeof **eh); eh[i][o] = j; } int n, m, col[N]; int dfs(int u, int p) { col[u] = 1; for (int v, j = 0; j < eo[u]; ++j) if ((v = eh[u][j]) != p) { if (col[v]) return 1; if (dfs(v, u)) return 1; } return 0; } int main() { scanf("%d%d", &n, &m); for (int u, v, i = 0; i < m; ++i) scanf("%d%d", &u, &v), pus(u, v), pus(v, u); if (dfs(1, 1)) { //puts("NO"); return 0; } puts("YES"); puts("1\n1"); }

Compilation message (stderr)

newspapers.c: In function 'pus':
newspapers.c:12:24: warning: suggest parentheses around '-' in operand of '&' [-Wparentheses]
   12 |   else if (0 == (o & o - 1)) eh[i] = (int*)realloc(eh[i], 2 * o * sizeof **eh);
      |                      ~~^~~
newspapers.c: In function 'main':
newspapers.c:30:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   30 |   scanf("%d%d", &n, &m);
      |   ^~~~~~~~~~~~~~~~~~~~~
newspapers.c:32:5: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   32 |     scanf("%d%d", &u, &v), pus(u, v), pus(v, u);
      |     ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...