Blog of RuSun

\begin {array}{c} \mathfrak {One Problem Is Difficult} \\\\ \mathfrak {Because You Don't Know} \\\\ \mathfrak {Why It Is Diffucult} \end {array}

P2447 [SDOI2010] 外星千足虫

P2447 [SDOI2010] 外星千足虫

题意很麻烦,直接上高斯消元。

查看代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <cstdio>
#include <bitset>
using namespace std;
const int N = 1e3 + 10, M = 2e3 + 10;
int n, m;
bitset<N> A[M];
void Gauss()
{
int res = 0;
for (int k = 1; k <= n; k++)
{
int t = k;
while (t <= m && !A[t][k])
t++;
if (t > m)
return puts("Cannot Determine"), void();
res = max(res, t);
swap(A[t], A[k]);
for (int i = 1; i <= m; i++)
i ^ k && A[i][k] && (A[i] ^= A[k], 0);
}
printf("%d\n", res);
for (int i = 1; i <= n; i++)
puts(A[i][0] ? "?y7M#" : "Earth");
}
int main ()
{
scanf("%d%d", &n, &m);
for (int i = 1, a; i <= m; i++)
{
for (int j = 1; j <= n; j++)
scanf("%1d", &a), A[i][j] = a;
scanf("%1d", &a), A[i][0] = a;
}
Gauss();
return 0;
}