记录编号 |
57589 |
评测结果 |
AAAAAWAA |
题目名称 |
[HAOI 2005]奇特的图案 |
最终得分 |
87 |
用户昵称 |
feng |
是否通过 |
未通过 |
代码语言 |
C++ |
运行时间 |
0.148 s |
提交时间 |
2013-04-11 10:14:22 |
内存使用 |
30.88 MiB |
显示代码纯文本
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<string>
using namespace std;
int n,N;
int M[2001][2001];
int L[2001];
int f[2001];
int g[2001][2001];
int x,y;
//ifstream fin("t3.in");
//ofstream fout("t3.out");
void swap(int x,int y)
{
for (int i=1;i<=n+1;i++)
{
M[0][i]=M[x][i];
M[x][i]=M[y][i];
M[y][i]=M[0][i];
}
}
void Delete(int x,int y)
{
for (int i=x;i<=n+1;i++)
M[y][i]^=M[x][i];
}
void work(){
for (int i=1;i<n;i++){
int p=i-1;
while (!M[++p][i] && p<=n);
if (p<=n){
swap(i,p);
for (int j=i+1;j<=n;j++)
if (M[j][i]) Delete(i,j);
}
}
for (int i=n;i>=1;i--)
{
int tmp=0;
for (int j=i+1;j<=n;j++)
tmp^=L[j]&M[i][j];
L[i]=M[i][n+1]^tmp;
}
int sum=0;
for (int i=1;i<=n;i++){
sum+=L[i];
}
printf("%d\n",sum);
//
}
void init(){
freopen("t3.in","r",stdin);
freopen("t3.out","w",stdout);
memset(M,0,sizeof(M));
memset(L,0,sizeof(L));
/*
char ch;
//string str;
scanf("%d\n",&n);
for (int i=1;i<=n;i++){
if (i==81){
int tmp;
tmp=0;
}
scanf("%c",&ch);
f[i]=ch-'0';
f[i]=!f[i];
scanf(" %c",&ch);
while (ch!='\n'){
int num=0;
while (ch!=' ' && ch!='\n'){
num=num*10+ch-'0';
if (scanf("%c",&ch)==EOF) return;
}
if (ch!='\n' && ch!=EOF)
if (scanf("%c",&ch)==EOF) return;
g[i][++g[i][0]]=num;
}
}*/
string ch;
scanf("%d\n",&n);
for (int i=1;i<=n;i++){
//scanf("%s\n",&ch1);
getline(cin,ch);
//ch=ch1;
int num;
f[i]=ch[0]-'0';
int len=ch.size();
num=0;
for (int j=1;j<len;j++){
char ss=ch[j];
if (ch[j]<='9' && ch[j]>='0')
num=num*10+ch[j]-'0';
if (ch[j]==' ' && num!=0){
g[i][++g[i][0]]=num;
num=0;
}
}
if (num!=0) g[i][++g[i][0]]=num;
num=0;
}
for (int i=1;i<=n;i++){
M[i][i]=1;
for (int j=1;j<=g[i][0];j++){
M[i][g[i][j]]=1;
M[g[i][j]][i]=1;
}
M[i][n+1]=!f[i];
}
}
int main()
{
init();
work();
return 0;
}