Submission #536552

#TimeUsernameProblemLanguageResultExecution timeMemory
536552rainboy전압 (JOI14_voltage)C11
10 / 100
1090 ms4092 KiB
#include <stdio.h> #include <string.h> #define N 100000 #define M 200000 int ds[N * 2]; 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() { static int ii[M], jj[M]; int n, m, h, h_, i, j, cnt; scanf("%d%d", &n, &m); for (h = 0; h < m; h++) scanf("%d%d", &ii[h], &jj[h]), ii[h]--, jj[h]--; cnt = 0; for (h = 0; h < m; h++) { memset(ds, -1, n * 2 * sizeof *ds); for (h_ = 0; h_ < m; h_++) { i = ii[h_], j = jj[h_]; if (h_ == h) join(i << 1 | 0, j << 1 | 0), join(i << 1 | 1, j << 1 | 1); else join(i << 1 | 0, j << 1 | 1), join(i << 1 | 1, j << 1 | 0); } cnt++; for (i = 0; i < n; i++) if (find(i << 1 | 0) == find(i << 1 | 1)) { cnt--; break; } } printf("%d\n", cnt); return 0; }

Compilation message (stderr)

voltage.c: In function 'main':
voltage.c:31:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   31 |  scanf("%d%d", &n, &m);
      |  ^~~~~~~~~~~~~~~~~~~~~
voltage.c:33:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   33 |   scanf("%d%d", &ii[h], &jj[h]), ii[h]--, jj[h]--;
      |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...