Submission #503211

#TimeUsernameProblemLanguageResultExecution timeMemory
503211rainboyKutije (COCI21_kutije)C11
70 / 70
226 ms9124 KiB
#include <stdio.h> #include <string.h> #define N 1000 int ds[N]; int find(int i) { return ds[i] < 0 ? i : (ds[i] = find(ds[i])); } void join(int i, int j) { i = find(i); j = find(j); if (i == j) return; if (ds[i] > ds[j]) ds[i] = j; else { if (ds[i] == ds[j]) ds[i]--; ds[j] = i; } } int main() { int n, m, q, i, j; scanf("%d%d%d", &n, &m, &q); memset(ds, -1, n * sizeof *ds); while (m--) for (i = 0; i < n; i++) { scanf("%d", &j), j--; join(i, j); } while (q--) { scanf("%d%d", &i, &j), i--, j--; printf(find(i) == find(j) ? "DA\n" : "NE\n"); } return 0; }

Compilation message (stderr)

Main.c: In function 'main':
Main.c:29:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   29 |  scanf("%d%d%d", &n, &m, &q);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
Main.c:33:4: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |    scanf("%d", &j), j--;
      |    ^~~~~~~~~~~~~~~
Main.c:37:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |   scanf("%d%d", &i, &j), i--, j--;
      |   ^~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...