# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
488534 | rainboy | Logičari (COCI21_logicari) | C11 | 26 ms | 284 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |