【BZOJ 1923】[Sdoi2010] 外星千足虫

题目传送门:http://www.lydsy.com/JudgeOnline/problem.php?id=1923
数据生成器:http://paste.ubuntu.com/18996088/

今天在做高斯消元的专题。一看这题,欸,这不高斯消元求解异或方程组的板题吗? (~ ̄▽ ̄)→))* ̄▽ ̄*)o
于是写了一写,果然是板题。然而我想只有我这种纸张才会因为把结果输反了而wa了半天吧?QAQ

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
using namespace std;

const int MAXN = 1000+9;

int n,m,mat[MAXN][MAXN],tmp[MAXN],cnt;
char pat[MAXN],tag[MAXN];

inline int read(){
	char c=getchar(); int buf=0,f=1;
	while (c<'0'||c>'9'){if(c='-')f=-1;c=getchar();}
	while (c<='9'&&c>='0'){buf=buf*10+c-'0';c=getchar();}
	return buf*f;
}

inline bool update(){
	for (int i=1;i<=n;i++) if (tmp[i]){
		if (!tag[i]) {
			tag[i] = 1; cnt++;
			for (int j=1;j<=n+1;j++) 
				mat[j][i] = tmp[j];
			return cnt == n;
		} else for (int j=1;j<=n+1;j++) tmp[j] ^= mat[j][i];
	}
	return cnt == n;
}

inline void output(int k){
	printf("%d\n",k);
	for (int i=n;i;i--){
		int ans = mat[n+1][i];
		for (int j=i+1;j<=n;j++)
			ans ^= mat[j][i];
		if (ans) tag[i] = 1;
		else tag[i] = 0;
		for (int j=i-1;j;j--)
			mat[i][j] *= ans;	
	}
	for (int i=1;i<=n;i++) 
		if (tag[i]) puts("?y7M#");
		else puts("Earth");
}

int main(){
	scanf("%d%d",&n,&m);
	for (int k=1;k<=m;k++){
		scanf("%s",pat+1); tmp[n+1]=read();
		for (int i=1;i<=n;i++)
			tmp[i] = pat[i]-'0';
		if (update()) output(k), exit(0);
	}
	puts("Cannot Determine\n");
	return 0;
} 

PS:这份代码是在线的做法,看题解,貌似离线也是可以做的。

27 thoughts to “【BZOJ 1923】[Sdoi2010] 外星千足虫”

  1. Very nice post. I just stumbled upon your blog and
    wanted to say that I’ve truly enjoyed browsing your blog posts.
    In any case I will be subscribing to your rss feed
    and I hope you write again very soon!

  2. First off I would like to say superb blog! I had
    a quick question which I’d like to ask if you don’t mind.
    I was curious to find out how you center yourself and clear your thoughts prior
    to writing. I have had a hard time clearing my mind in getting my thoughts
    out there. I truly do take pleasure in writing however it
    just seems like the first 10 to 15 minutes are generally lost just trying to figure out how to begin. Any recommendations or
    hints? Thank you!

  3. Please let me know if you’re looking for a author for your weblog.
    You have some really great articles and I feel I would be a good asset.
    If you ever want to take some of the load off, I’d really like to write some material for your blog in exchange for a link back
    to mine. Please send me an e-mail if interested.
    Cheers!

  4. Hi there, I discovered your website by way of Google while looking for a related topic, your
    site came up, it looks great. I have bookmarked it in my google
    bookmarks.
    Hi there, simply turned into aware of your blog via Google, and
    located that it’s truly informative. I am going to watch
    out for brussels. I will appreciate in case you proceed this in future.
    Lots of other people might be benefited out of your writing.

    Cheers!

  5. Nice blog right here! Additionally your website lots up very fast!
    What web host are you using? Can I am getting your associate hyperlink in your host?
    I want my website loaded up as fast as yours lol

  6. I just like the helpful information you supply in your articles.
    I will bookmark your blog and test again here regularly. I
    am reasonably certain I’ll be informed lots of new stuff proper right here!

    Good luck for the next!

  7. Thank you for every other informative site. Where else may just I get that kind of info written in such an ideal method?
    I’ve a challenge that I am just now working on, and I’ve been on the look out for such info.

  8. Whats up this is kinda of off topic but I was wondering if
    blogs use WYSIWYG editors or if you have to manually code with HTML.
    I’m starting a blog soon but have no coding skills so I
    wanted to get advice from someone with experience. Any help would be enormously appreciated!

  9. This is really interesting, You are a very
    skilled blogger. I have joined your feed and look forward to seeking more of your fantastic post.
    Also, I have shared your web site in my social networks!

  10. hello there and thank you to your information – I have certainly picked up anything new from right here. I did on the other hand expertise a few technical points the use of this site, as I experienced to reload the web site lots of instances previous to I could get it to load properly. I have been brooding about if your web host is OK? Now not that I am complaining, however sluggish loading circumstances occasions will sometimes impact your placement in google and can injury your high quality rating if advertising and ***********|advertising|advertising|advertising and *********** with Adwords. Anyway I’m including this RSS to my e-mail and could look out for much more of your respective intriguing content. Ensure that you replace this once more very soon..

  11. I would like to thank you for the efforts you’ve put in writing
    this website. I really hope to check out the same
    high-grade content from you in the future as well.
    In truth, your creative writing abilities has inspired me to get my own, personal website
    now 😉

  12. This is very attention-grabbing, You are a very skilled blogger.
    I’ve joined your rss feed and look ahead to searching for extra of your fantastic
    post. Additionally, I have shared your web site in my social networks

  13. I take pleasure in, result in I found exactly what I used to be looking for.
    You have ended my four day long hunt! God Bless you man. Have a great day.

    Bye

  14. If some one desires expert view about blogging and site-building
    afterward i advise him/her to pay a visit this weblog,
    Keep up the good work.

  15. Heya i’m for the first time here. I came across this board and I find It truly useful & it helped me out
    a lot. I hope to give something back and
    help others like you aided me.

  16. Simply want to say your article is as surprising.

    The clearness on your submit is simply nice and i could
    think you’re a professional in this subject. Well together with your permission let me to grasp
    your RSS feed to stay up to date with impending post. Thank you a million and please continue the
    enjoyable work.

  17. Hello There. I discovered your blog the usage of msn. That is an extremely smartly written article.
    I will be sure to bookmark it and return to read more of your useful info.
    Thank you for the post. I will definitely return.

  18. It?¦s really a great and useful piece of information. I?¦m glad that you just shared this useful information with us. Please stay us informed like this. Thanks for sharing.

Leave a Reply

Your email address will not be published. Required fields are marked *