Submission #488534

#TimeUsernameProblemLanguageResultExecution timeMemory
488534rainboyLogičari (COCI21_logicari)C11
20 / 110
26 ms284 KiB
#include <stdio.h> #define N 20 int min(int a, int b) { return a < b ? a : b; } int main() { static int bb[N]; int n, h, i, j, b, k_; scanf("%d", &n); if (n > N) { printf("%d\n", n % 4 == 0 ? n / 2 : -1); return 0; } for (h = 0; h < n; h++) { scanf("%d%d", &i, &j), i--, j--; bb[i] |= 1 << j, bb[j] |= 1 << i; } k_ = n + 1; for (b = 0; b < 1 << n; b++) { int b_ = 0, k = 0; for (i = 0; i < n; i++) if ((b & 1 << i) != 0) { if ((b_ & bb[i]) != 0) { b_ = -1; break; } b_ |= bb[i], k++; } if (b_ == (1 << n) - 1) k_ = min(k_, k); } if (k_ == n + 1) k_ = -1; printf("%d\n", k_); return 0; }

Compilation message (stderr)

Main.c: In function 'main':
Main.c:11:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   11 |  scanf("%d", &n);
      |  ^~~~~~~~~~~~~~~
Main.c:17:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
   17 |   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...