Submission #70304007
Source Code Expand
Copy
#include <stdio.h>int N, M;int u[1024], v[1024];int main(void) {int i, j;int ans = 9999;if (scanf("%d%d", &N, &M) != 2) return 1;for (i = 0; i < M; i++) {if (scanf("%d%d", &u[i], &v[i]) != 2) return 1;u[i]--;v[i]--;}for (i = 0; i < (1 << N); i++) {int cur = 0;for (j = 0; j < M; j++) {if (((i >> u[j]) & 1) == ((i >> v[j]) & 1)) cur++;}if (cur < ans) ans = cur;}
#include <stdio.h>
int N, M;
int u[1024], v[1024];
int main(void) {
int i, j;
int ans = 9999;
if (scanf("%d%d", &N, &M) != 2) return 1;
for (i = 0; i < M; i++) {
if (scanf("%d%d", &u[i], &v[i]) != 2) return 1;
u[i]--;
v[i]--;
}
for (i = 0; i < (1 << N); i++) {
int cur = 0;
for (j = 0; j < M; j++) {
if (((i >> u[j]) & 1) == ((i >> v[j]) & 1)) cur++;
}
if (cur < ans) ans = cur;
}
printf("%d\n", ans);
return 0;
}
Submission Info
| Submission Time | |
|---|---|
| Task | C - Bipartize |
| User | mikecat |
| Language | C (gcc 12.2.0) |
| Score | 350 |
| Code Size | 466 Byte |
| Status | AC |
| Exec Time | 1 ms |
| Memory | 1748 KiB |
Judge Result
| Set Name | Sample | All | ||||
|---|---|---|---|---|---|---|
| Score / Max Score | 0 / 0 | 350 / 350 | ||||
| Status |
|
|
| Set Name | Test Cases |
|---|---|
| Sample | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt |
| All | 00_sample_00.txt, 00_sample_01.txt, 00_sample_02.txt, 01_random_03.txt, 01_random_04.txt, 01_random_05.txt, 01_random_06.txt, 01_random_07.txt, 01_random_08.txt, 01_random_09.txt, 01_random_10.txt, 01_random_11.txt, 01_random_12.txt, 01_random_13.txt, 01_random_14.txt, 01_random_15.txt, 01_random_16.txt, 01_random_17.txt, 01_random_18.txt, 01_random_19.txt, 01_random_20.txt, 01_random_21.txt, 01_random_22.txt, 01_random_23.txt, 01_random_24.txt |
| Case Name | Status | Exec Time | Memory |
|---|---|---|---|
| 00_sample_00.txt | AC | 1 ms | 1640 KiB |
| 00_sample_01.txt | AC | 1 ms | 1592 KiB |
| 00_sample_02.txt | AC | 1 ms | 1636 KiB |
| 01_random_03.txt | AC | 1 ms | 1632 KiB |
| 01_random_04.txt | AC | 1 ms | 1632 KiB |
| 01_random_05.txt | AC | 1 ms | 1644 KiB |
| 01_random_06.txt | AC | 0 ms | 1632 KiB |
| 01_random_07.txt | AC | 1 ms | 1712 KiB |
| 01_random_08.txt | AC | 1 ms | 1716 KiB |
| 01_random_09.txt | AC | 1 ms | 1740 KiB |
| 01_random_10.txt | AC | 1 ms | 1720 KiB |
| 01_random_11.txt | AC | 0 ms | 1628 KiB |
| 01_random_12.txt | AC | 1 ms | 1576 KiB |
| 01_random_13.txt | AC | 1 ms | 1708 KiB |
| 01_random_14.txt | AC | 1 ms | 1748 KiB |
| 01_random_15.txt | AC | 1 ms | 1628 KiB |
| 01_random_16.txt | AC | 1 ms | 1728 KiB |
| 01_random_17.txt | AC | 0 ms | 1644 KiB |
| 01_random_18.txt | AC | 0 ms | 1580 KiB |
| 01_random_19.txt | AC | 1 ms | 1620 KiB |
| 01_random_20.txt | AC | 1 ms | 1720 KiB |
| 01_random_21.txt | AC | 0 ms | 1716 KiB |
| 01_random_22.txt | AC | 0 ms | 1636 KiB |
| 01_random_23.txt | AC | 1 ms | 1744 KiB |
| 01_random_24.txt | AC | 1 ms | 1720 KiB |